This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
RTTI problem
- From: "Folker Schamel" <schamel at spinor dot com>
- To: <gcc-bugs at gcc dot gnu dot org>
- Date: Mon, 2 Dec 2002 04:33:14 +0100
- Subject: RTTI problem
- References: <1038798858.7777.ezmlm@gcc.gnu.org>
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