gcc3 vs 176.gcc
Joseph S. Myers
jsm28@cam.ac.uk
Wed Jan 9 13:06:00 GMT 2002
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
More information about the Gcc
mailing list