------- Comment #8 from zak at transversal dot com 2006-08-18 11:21 ------- However, that patch breaks the following code, which requires *implicit* derived-to-base conversion:
================================ struct Z {}; struct A : Z {}; Z* implicitToZ (Z*); struct B : A { static const int i = sizeof(implicitToZ((B*)0)); }; ================================ Without the patch, the above compiles cleanly (as it does in 4.0.3, 4.1.1 and Comeau). With the patch, I get: $ g++ -c dtob.cc dtob.cc:8: error: invalid conversion from 'B*' to 'Z*' dtob.cc:8: error: initializing argument 1 of 'Z* implicitToZ(Z*)' The standard (in 4.10 [conv.ptr], paragraph 3) states that a program requiring a derived-to-base conversion is ill-formed if the base class is inaccessible or ambiguous; it does not mention any requirement that the derived class must be complete. This breaks code like this using boost::is_base_and_derived (this is cut down from a real-world example): ================================ #include <boost/type_traits/is_base_and_derived.hpp> #include <boost/static_assert.hpp> struct Base { }; template< typename T > struct A { BOOST_STATIC_ASSERT(( boost::is_base_and_derived< Base, T >::value )); struct Inner { }; }; struct Derived : Base { typedef A< Derived >::Inner Inner; }; ================================ -- zak at transversal dot com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |zak at transversal dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27177