[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Possible Bug - g++ 3.4.0 and GotW #17
From: |
llewelly |
Subject: |
Re: Possible Bug - g++ 3.4.0 and GotW #17 |
Date: |
Thu, 27 May 2004 14:45:52 -0600 |
User-agent: |
Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (berkeley-unix) |
Jan Rendek <do@not.use> writes:
> 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 ?
I suggest you either write a bug report, or raise the issue of its
correctness on e.g. comp.std.c++ .