From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Martin v. Loewis" To: mark@codesourcery.com Cc: nik@tiuk.ti.com, tim@franck.Princeton.EDU, egcs@egcs.cygnus.com, george@moberg.com Subject: Re: Clarification anyone? -- was Re: Linux and aliasing? Date: Tue, 08 Jun 1999 15:47:00 -0000 Message-id: <199906082213.AAA00692@mira.isdn.cs.tu-berlin.de> References: <199906081731.KAA16675@franck.Princeton.EDU> <199906081732.SAA13273@tiuk.ti.com> <19990608104553V.mitchell@codesourcery.com> <19990608104553V.mitchell@codesourcery.com> X-SW-Source: 1999-06/msg00308.html > 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Martin v. Loewis" To: mark@codesourcery.com Cc: nik@tiuk.ti.com, tim@franck.Princeton.EDU, egcs@egcs.cygnus.com, george@moberg.com Subject: Re: Clarification anyone? -- was Re: Linux and aliasing? Date: Wed, 30 Jun 1999 15:43:00 -0000 Message-ID: <199906082213.AAA00692@mira.isdn.cs.tu-berlin.de> References: <199906081731.KAA16675@franck.Princeton.EDU> <199906081732.SAA13273@tiuk.ti.com> <19990608104553V.mitchell@codesourcery.com> X-SW-Source: 1999-06n/msg00308.html Message-ID: <19990630154300.FIj_Oq_qneg4iv3OgdZlCBoNQpORWgBgcxuo0SWZECA@z> > 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