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: 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


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