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:

> 	void foo (int *ip, float *fp)
> 	{
> 		if (ip == fp)
> 			this_is_unreachable ()
> 	}

A followup to my last mail.  Think about this:

void bar ()
{
  int i;
  int *ip = &f;
  foo ( ip, (float *)ip);
}

Suppose, that in your foo() for the compare 'fp' is casted to 'int*'
(maybe because it has looser alignment).  Then it's required per
6.3.2.3 #7 to compare equal to the original pointer, which is ip.


Ciao,
Michael.


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