On Apr 24, 2010, at 3:59 PM, ext Bruno Haible wrote: > Jarno Rajahalme wrote: >> These warnings only show with -O, so this is related to optimization. >> >> I have included the preprocessed output (main.cpp). >> >> Compiled with: >> g++-mp-4.4 -DHAVE_CONFIG_H -I.. -I../lib -O1 -E -dD -c -o main.cpp main.cc > > Thanks. I've reduced this to a test case and reported it as a GCC bug: > <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881> > > There are three possible ways to handle this: > a) Change the initializer from ::func to ((void)0,::func). > This has the effect of getting rid of the warning, but creates lots of > initialized variables in the 'data' segment, for every compilation unit. > I.e. it bloats the compiled code. > b) Change the warning to be enabled when !__OPTIMIZE__. This means that > with default optimization flags (-O2 -g), no warnings will be visible. > c) Leave it as it, and document that users should look at the warnings only > with -O0. > > I'm not sure which one you prefer? >
I personally would prefer b). Having hundreds of spurious warnings totally swamps any other possible warnings, that might be useful even when compiling with optimization. Regards, Jarno