This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ISO Aliasing rules question


 >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 at codesourcery dot com
CodeSourcery, LLC            http://www.codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]