is_base_and_derived instantiated from within derived class definition

I have a piece of code which boils down to: ====================================== #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; }; ======================================= This had been compiling fine with gcc 3.3 up to 4.1.1, but the assertion fails on the current 4.1.2 snapshot as a result of the fix for PR 27177 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27177) because Derived is incomplete -- although its base class is already known. The failure basically comes down to code like this: ======================================= struct Z {}; struct A : Z {}; Z* implicitToZ (Z*); struct B : A { static const int i = sizeof(implicitToZ((B*)0)); }; ======================================== This compiles up to gcc 4.1.1, and also with Comeau (try pasting it into http://www.comeaucomputing.com/tryitout/), but not with the gcc 4.1.2 snapshot.
From discussion on the above bug page, it appears unclear whether this or not this code is actually legal... has the patch broken something which should be expected to work, or are the existing versions of gcc and Comeau accepting illegal code?
Zak.

Zak Kipling wrote:
From discussion on the above bug page, it appears unclear whether this or not this code is actually legal... has the patch broken something which should be expected to work, or are the existing versions of gcc and Comeau accepting illegal code?
It looks borderline to me: I suspect that gcc is correct in complaining about this, of course that doesn't mean it *has* to diagnose this as an error, simply that it is probably permitted to do so. Any other opinions? John.

"John Maddock" <john@johnmaddock.co.uk> writes:
Zak Kipling wrote:
From discussion on the above bug page, it appears unclear whether this or not this code is actually legal... has the patch broken something which should be expected to work, or are the existing versions of gcc and Comeau accepting illegal code?
It looks borderline to me: I suspect that gcc is correct in complaining about this, of course that doesn't mean it *has* to diagnose this as an error, simply that it is probably permitted to do so.
Any other opinions?
I agree. -- Dave Abrahams Boost Consulting www.boost-consulting.com

On Mon, 11 Sep 2006 13:17:00 +0100, "John Maddock" <john@johnmaddock.co.uk> wrote:
Zak Kipling wrote:
From discussion on the above bug page, it appears unclear whether this or not this code is actually legal... has the patch broken something which should be expected to work, or are the existing versions of gcc and Comeau accepting illegal code?
It looks borderline to me: I suspect that gcc is correct in complaining about this, of course that doesn't mean it *has* to diagnose this as an error, simply that it is probably permitted to do so.
But why? I can't see anything in the standard supporting this point of view. To Zak: what's the point of having the class Z in your example? -- [ Gennaro Prota. C++ developer, Library designer. ] [ For Hire http://gennaro-prota.50webs.com/ ]
participants (4)
-
David Abrahams
-
Gennaro Prota
-
John Maddock
-
Zak Kipling