https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71402

--- Comment #10 from andysem at mail dot ru ---
$ cat gcc_unused_variable.h
class Foo
{
public:
    static bool init();
};

static bool FooInit = Foo::init();
$ cat gcc_unused_variable.cpp
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#include "gcc_unused_variable.h"
#pragma GCC diagnostic pop

int main()
{
    return 0;
}
$ g++ -Wall -O3 -o gcc_unused_variable.o -c gcc_unused_variable.cpp
In file included from gcc_unused_variable.cpp:3:0:
gcc_unused_variable.h:7:13: warning: ‘FooInit’ defined but not used
[-Wunused-variable]
 static bool FooInit = Foo::init();
             ^

Reply via email to