[Developers] g++ warning: operation on *bla* may be undefined

Jonathan Thornburg jthorn at aei.mpg.de
Fri Oct 27 01:19:09 CDT 2006


Hi,

On Thu, 26 Oct 2006, Erik Schnetter wrote:
> to the source code.  If you want to suppress warnings for all compilers,
> combine both approaches:
> 
> 	int x = sizeof(var);
> 	int * y = & var + 1;
> 
> Thus, both compilers will see that var is used in some way.

Alas, in many compilers (including gcc), if you take & of a variable
anywhere in a function, that variable is *never* allocated to a register
anywhere in that function.  This can really hurt optimization.  (The
gcc manual explicitly warns about this!)

Anywhere the compiler supports it, using __attribute__((unused)) et al
is both higher-performance and cleaner.  I would prefer that we do this,
and only fall back to the anti-optimization techniques if we have to.

ciao,

-- 
-- Jonathan Thornburg <jthorn at aei.mpg.de>      
   Max-Planck-Institut fuer Gravitationsphysik (Albert-Einstein-Institut),
   Golm, Germany, "Old Europe"     http://www.aei.mpg.de/~jthorn/home.html      
   "Washing one's hands of the conflict between the powerful and the
    powerless means to side with the powerful, not to be neutral."
                                      -- quote by Freire / poster by Oxfam



More information about the Developers mailing list