This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: dynamic_cast behavior differs from standard?
- To: David Mazieres <dm at reeducation-labor dot lcs dot mit dot edu>
- Subject: Re: dynamic_cast behavior differs from standard?
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 24 Feb 1999 02:59:22 -0300
- Cc: egcs at cygnus dot com
- References: <199902240040.TAA15648@reeducation-labor.lcs.mit.edu>
On Feb 23, 1999, David Mazieres <dm@reeducation-labor.lcs.mit.edu> wrote:
> 5.2.7.8 says of the run-time check done by dynamic_cast:
[snip]
> Thus, the output I would expect would be:
> bp is NULL
> bbp is NULL
> bigger:: bp is NULL
> bigger:: bbp is NULL
> Since all compilers do seem to give special dynamic_casts powers to
> friends and methods, and doing so must require additional
> implementation work in the compiler, I'm willing to believe this is in
> fact correct behavior.
I don't think so. Even if you remove the `friend' declarations, the
result is still wrong. The bug is that dynamic_cast fails to check
whether the source type is a public base class of the target type, as
required in the Standard.
--
Alexandre Oliva http://www.dcc.unicamp.br/~oliva aoliva@{acm.org}
oliva@{dcc.unicamp.br,gnu.org,egcs.cygnus.com,samba.org}
Universidade Estadual de Campinas, SP, Brasil