Boost logo

Boost :

From: Zak Kipling (zak_at_[hidden])
Date: 2006-09-11 06:25:00


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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk