This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


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: Is this expected gcc behaviour?


On Fri, Aug 06, 2004 at 11:08:08AM -0700, Aaron J. Grier wrote:

> if newer versions of gcc are optimizing this out (and according to C
> standard that's OK), how else can this be accomplished?

The version of gcc I'm using (3.3) doesn't optimize away the
test of an external objects address, so I can't test this, but
how about:


extern unsigned char v;  // address of v is defined at link time

void foo(void)
{
  volatile unsigned long u = (unsigned long)&v;
  if (u)
    bar();  
}

-- 
Grant Edwards
grante@visi.com

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


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