This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/71402] -Wunused-variable warnings ignore initialization side effects


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();
             ^

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]