[Developers] g++ warning: operation on *bla* may be undefined
Jonathan Thornburg
jthorn at aei.mpg.de
Thu Oct 26 09:45:21 CDT 2006
Hi,
On Thu, 26 Oct 2006, Erik Schnetter wrote:
> gcc has __attribute__((unused)) to mark variables that are intentionally
> unused. This suppresses this warning. Other compilers may have similar ways
> for annotating variables.
>
> I have implemented a bit of generic infrastructure to declare variables, which
> makes it easier to experiment with these things. I have also implemented
> autodetecting whether __attribute__((unused)) is supported, so that it is used
> when present, and an old-style mechanism is used otherwise. A similar thing
> is done for Fortran code.
>
> The changes are straightforward, but touch quite a number of files. I would
> need to isolate them from other changes, and then they need to be tested
> thoroughly. I can do the first part if you are interested.
>
> We discussed this before, and then the consensus was that using
> __attribute__((unused)) was not worth the effort because the existing
> mechanisms were sufficient. Maybe this has changed with gcc 4 having become
> too clever.
IMHO Erik's suggestion of using __attribute__((unused)) is the right
way to solve this problem, while our current approach of trying to fool
compilers is a chronic hassle which is gradually getting less effective
as compilers get smarter.
Erik, I would be happy to test your __attributre__((unused)) patches
with gcc in my Cactus compiles...
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