ISO Aliasing rules question
Mark Mitchell
mark@codesourcery.com
Fri Feb 21 20:03:00 GMT 2003
> >Bottom line: the optimization in the code you showed is correct.
> Meaning that execute/20000603-1.c is a bogus test :-)
The key thing there is that b doesn't really point to an s2, so accesses
through it are invalid. Although I can't find the part of the standard
that says that any more!
The C++ standard has this language:
If a program attempts to access the stored value of an object through
an lvalue of other than one of the following types the behavior is
undefined25):
--the dynamic type of the object,
...
The problem here is that b doesn't have the dynamic type s2.
I think the C standard has similar language -- somewhere.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
More information about the Gcc
mailing list