is_polymorphic type_trait question

I have the following little test program #include <boost/static_assert.hpp> #include <boost/type_traits/is_polymorphic.hpp> struct vbase { }; struct derived : public virtual vbase { }; // VC 7.1, borland 5.51 and Commeau trap here (gcc 3.2 doesn't trap here!) BOOST_STATIC_ASSERT(boost::is_polymorphic<derived>::value); // everything including gcc traps here ! BOOST_STATIC_ASSERT(boost::is_polymorphic<vbase>::value); int main(int argc, char *argv[]) { } This suggests to me that is_polymorphic returns true for a class derived virtually from a base class under the gcc compiler even though the base class has no virtual function!

"Robert Ramey" <ramey@rrsd.com> writes:
I have the following little test program
#include <boost/static_assert.hpp> #include <boost/type_traits/is_polymorphic.hpp>
struct vbase { };
struct derived : public virtual vbase { };
// VC 7.1, borland 5.51 and Commeau trap here (gcc 3.2 doesn't trap here!) BOOST_STATIC_ASSERT(boost::is_polymorphic<derived>::value);
I think this is a problem and I doubt we can implement an is_polymorphic that does the right thing on gcc for this case.
// everything including gcc traps here ! BOOST_STATIC_ASSERT(boost::is_polymorphic<vbase>::value);
One would expect it to. vbase is not polymorphic!
int main(int argc, char *argv[]) { }
This suggests to me that is_polymorphic returns true for a class derived virtually from a base class under the gcc compiler even though the base class has no virtual function!
Seems so. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com
participants (2)
-
David Abrahams
-
Robert Ramey