[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Possible Bug - g++ 3.4.0 and GotW #17
From: |
Jan Rendek |
Subject: |
Possible Bug - g++ 3.4.0 and GotW #17 |
Date: |
Thu, 27 May 2004 12:43:54 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.4) Gecko/20030630 |
Hi all,
While reading the Guru of the Week archive, more
precisly item 17. I tried the following code.
class A { public: virtual ~A(){} };
class B : virtual A { public: virtual ~B(){} };
struct C : A { /* EMPTY */ };
struct D : B, C { /* EMPTY */ };
D d1;
int main()
{
B* pb4 = &d1;
A* pa1 = dynamic_cast<A*>(pb4); // (1)
}
According to H. Sutter the dynamic_cast (1) is correct
since "pb4 points to the object d1, and D does have A
as an indirect public base class (through C), and
dynamic_cast is able to cast across the inheritance
hierarchy using the path B* -> D* -> C* -> A*."
However using g++ 3.4.0 it fails to compile. Producing
the following error:
error: `A' is an inaccessible base of `B'
Am I missing something here, or shall I write bug report ?
--
Jan Rendek
INRIA Lorraine
r e n d e k @ l o r i a . f r