Boost logo

Boost :

Subject: Re: [boost] bug in type_traits/is_virtual_base_of ??
From: Daniel Larimer (dlarimer_at_[hidden])
Date: 2010-02-12 09:06:49


On Feb 12, 2010, at 6:53 AM, John Maddock wrote:

>> What do you think? Any potential problems / side effects?
>
> Unfortunately it breaks the existing tests with all the gcc versions I tried (win32 and Linux) :-(
>

Are we looking at the same code? Have you been able to verify the padding problem? Do your tests at least confirm that my "patch" works for the test case I outlined? My patch seems to work (for my test case) for both Mac OS X and debian linux. gcc 4.2.1 and 4.3.2 respectively.

What test case is it failing?

Here are the full set of tests I ran on linux with my "hacked" version of is_virtual_base

#include <stdio.h>
#include "is_virtual_base_of.hpp"
#include <stdint.h>

struct A
{
    int x;
};
struct B
{
    int y;
};

struct C : public A, public B
{
    int z;
};

struct D : public A, virtual public B
{
    int z;
};

struct E : public A, public B
{
    virtual void test(){};
    int z;
};

struct F : virtual public B
{
    virtual void test(){};
    int z;
};

struct G : public B, public A
{
    virtual void test(){};
    int t;
};
struct H : public B, public A
{
    int t;
};
struct I : virtual public B
{
    int t;
};
struct J : public B
{
    int t;
};

int main( int argc, char** argv )
{
    printf( "A,C %d\n", (int)boost::is_virtual_base_of<A,C>::value );
    printf( "B,C %d\n", (int)boost::is_virtual_base_of<B,C>::value );

    printf( "A,D %d\n", (int)boost::is_virtual_base_of<A,D>::value );
    printf( "virtual B,D %d\n", (int)boost::is_virtual_base_of<B,D>::value );

    printf( "A,E %d\n", (int)boost::is_virtual_base_of<A,E>::value );
    printf( "B,E %d\n", (int)boost::is_virtual_base_of<B,E>::value );
    printf( "virtual B,F %d\n", (int)boost::is_virtual_base_of<B,F>::value );
    printf( "B,G %d\n", (int)boost::is_virtual_base_of<B,G>::value );
    printf( "A,G %d\n", (int)boost::is_virtual_base_of<A,G>::value );
    printf( "virtual B,I %d\n", (int)boost::is_virtual_base_of<B,I>::value );
    printf( "B,J %d\n", (int)boost::is_virtual_base_of<B,J>::value );
}

==========================================
A,C 0
B,C 0
A,D 0
virtual B,D 1
A,E 0
B,E 0
virtual B,F 1
B,G 0
A,G 0
virtual B,I 1
B,J 0

> John.
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


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