https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84221
Bug ID: 84221 Summary: spurious -Wmaybe-uninitialized warning on a variable of a template type declared unused Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- As Jason points out in https://gcc.gnu.org/ml/gcc-patches/2018-02/msg00197.html, issuing -Wunused-variable for definition of the local 'a' in the test case below is a false positive: $ cat y.C && gcc -O2 -S -Wall -Wextra y.C template <class T> struct [[gnu::unused]] A { }; template <> struct A<int> { }; void f (void) { A<int> a; // shouldn't warn } y.C: In function ‘void f()’: y.C:6:10: warning: unused variable ‘a’ [-Wunused-variable] A<int> a; // shouldn't warn ^