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: Type based aliasing


Hi,

On Wed, 2 Oct 2002, Nathan Sidwell wrote:

> Hi,
> Do C's type based aliasing rules mean the following?
> 	void foo (int *ip, float *fp)
> 	{
> 		if (ip == fp)
> 			this_is_unreachable ()
> 	}

Why should it?  The accessed values are 'ip' and 'fp' itself and they are
accessed through their effective type.  So 6.5.7 is fullfilled, ergo the
accesses to 'ip' and 'fp' are defined.  The compare itself is Ok, as even
if everything breaks, one of the two pointer can be converted to the other
pointer type, which is only undefined, if alignment rules of that type are
not followed.


Ciao,
Michael.


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