The attached program gives a warning about 'check_moo' being unused, despite the variable being declared with __attribute__ ((__unused__)).
================================= bug.cc ================================== extern "C" int c_foo (void); namespace gnulib { static int (*foo) (void) = ::c_foo; } static int (* __attribute__ ((__unused__)) check_foo) (void) = gnulib::foo; extern "C" int c_moo (void); namespace gnulib { static int (*const moo) (void) = ::c_moo; } static int (* __attribute__ ((__unused__)) check_moo) (void) = gnulib::moo; =========================================================================== $ g++ -Wall -S bug.cc bug.cc:7: warning: 'check_moo' defined but not used The warning is present in all g++ version of 3.x and 4.x that I tested, except in g++ 4.0.2. I.e. "Known to work" = 4.0.2, "Known to fail" = 4.0.4, 4.1.2, 4.2.4, 4.3.4, 4.4.3. The only difference between check_foo (which does not elicit a warning) and check_moo is the 'const'ness of the initializer. -- Summary: warning with -Wall despite __attribute__ ((__unused__)) Product: gcc Version: 4.4.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: bruno at clisp dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43454