This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RTTI problem


Hello, 

using gcc 3.2, it seems that dynamic_cast cannot cast to a 
polymorophic class having no non-abstract virtual function.
For example:

class B
{
public:
    virtual ~B() {}
};

class D1: public B
{
}

class D2: public D1
{
public:
    virtual ~D2() {}
};

void main()
{
    B *b = new D2;
    D1 *d1 = dynamic_cast<D1*>(B);
    // Now d1 is zero with gcc 3.2
}

The reason seems to be that D1 has no RTTI information,
because there is no non-abstract virtual function.

On the other hand, I understand the C++ ANSI spec in that way
that d1 should be not 0, because both D2 and D1 are polymorphic types.

So it seems to be a gcc bug.
Is this right?

Greetings,
Folker



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]