This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: ISO Aliasing rules question
- From: Mark Mitchell <mark at codesourcery dot com>
- To: "law at redhat dot com" <law at redhat dot com>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Fri, 21 Feb 2003 11:54:15 -0800
- Subject: 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