Clarification anyone? -- was Re: Linux and aliasing?

Martin v. Loewis martin@mira.isdn.cs.tu-berlin.de
Wed Jun 30 15:43:00 GMT 1999


>     Nick> Even in the same function?
> 
> Right.

In some cases, flow analysis will detect that the value is clobbered.
Consider

unsigned long foo()
{
   unsigned long a=15;
    *((short *) &a) = 123;
   return a;
}

Compiling this with gcc-2.95 19990606 -O2 -fomit-frame-pointer gives
me

foo:
	movl $123,%eax
	ret

so the compiler clearly detects that a has been changed. The case that
doesn't work as before is

short *bar(unsigned long *a)
{
  return (short*)a;
}

unsigned long foo()
{
   unsigned long a;
   short *addr =  *bar(&a);
   a = 15;
   *addr = 123;
   return a;
}

Regards,
Martin



More information about the Gcc mailing list