https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104142
Bug ID: 104142 Summary: [9/10/11/12] Spurios warning unused-variable Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: phdiv at fastmail dot fm Target Milestone: --- Created attachment 52238 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52238&action=edit Reproducer. > cat c.cpp struct A { }; static const A a; struct B { B()=default; }; static const B b; > g++ -Wunused-variable -Wunused-const-variable -c c.cpp c.cpp:5:16: warning: 'b' defined but not used [-Wunused-variable] 5 | static const B b; | ^ c.cpp:2:16: warning: 'a' defined but not used [-Wunused-const-variable=] 2 | static const A a; | ^ I would expect the warning unused-const-variable to be issued for both a and b.