Compilation error
Dave Dodge
dododge at dododge.net
Mon Sep 10 04:19:43 UTC 2007
On Sun, Sep 09, 2007 at 09:39:28AM -0600, Greg Haerr wrote:
> : ((type)x)++
> Will gcc 4.x optimize this out if the temp variable is auto?
Very likely, especially if the value is held in a register and the
bitwise representation before and after the cast is the same. Note
that recent gcc uses a "static single assignment" technique, which as
a normal matter of operation creates unnamed temporary variables all
over the place. My understanding is that if you give it code like
this:
int a = 1;
a = 99;
a = 0;
int b = a;
it effectively converts it into something like this:
int const a___0 = 1;
int const a___1 = 99;
int const a___2 = 0;
int const b___0 = a___2;
So don't be afraid of creating temp variables, especially with newer
versions of gcc.
-Dave Dodge
More information about the uClibc
mailing list