help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Possible Bug - g++ 3.4.0 and GotW #17


From: Paul Pluzhnikov
Subject: Re: Possible Bug - g++ 3.4.0 and GotW #17
Date: 27 May 2004 21:48:37 -0700
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Artificial Intelligence)

Jan Rendek <do@not.use> writes:

> http://www.gotw.ca/gotw/017.htm
> 
> According to the above article the dynamic_cast is valid.

The argument in the article looks bogus: after the 'B* pb4 = &d1;'
assignment has executed, pb4 points into the 'B' sub-object of d1,
and neither the compiler nor the runtime system has any way to tell
that it really is part of a bigger "whole", and that this bigger
"whole" has *another* instance of 'A', which therefore must be
considered in determining the outcome of the dynamic_cast.

Besides, given the argument in the article, one would expect this
to compile:

   D* pd = &d1;
   A* pa = dynamic_cast<A*>(pd);

but it doesn't:

"junk.cc", line 15: error: base class "A" is ambiguous
     A* pa = dynamic_cast<A*>(pd);
                               ^
I believe this error is correct, but too lazy to dig up the right
sentence in the standard.

Anyway, you can have all the fun splitting hair in comp.std.c++

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]