This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: gcc3 vs 176.gcc
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- To: Joe Buck <jbuck at synopsys dot COM>
- Cc: <dewar at gnat dot com>, <aj at suse dot de>, <dalej at apple dot com>, <gcc at gcc dot gnu dot org>
- Date: Wed, 9 Jan 2002 20:44:47 +0000 (GMT)
- Subject: Re: gcc3 vs 176.gcc
On Wed, 9 Jan 2002, Joe Buck wrote:
> The idea: we have a pointer of type T1, and there is a dereference
> based on a casted-to-T2 form of that pointer, where T1 and T2 aren't
> compatible types for the purpose of the aliasing rule. For example
> T1 * p;
> ...
> *((T2 *)p = value;
> or
> ((T2 *)p)[expression] = value;
> (or alternatively a read). The key is that the pointer is converted
> to an incompatible type, and then dereferenced, possibly after adding
> an offset.
Such code does not necessarily violate the aliasing rules - unless the
same object is accessed in both types. If alignment permits, it is valid
(albeit bad style) for the pointer to be stored as type T1 *, but the only
accesses through it being of objects of type T2. So the warning should
only be if we prove the accesses to access the same byte, while type-based
aliasing says they don't conflict.
--
Joseph S. Myers
jsm28@cam.ac.uk