https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79548
Bug ID: 79548 Summary: missing -Wunused-variable on a typedef'd variable in a function template Product: gcc Version: 7.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: --- GCC diagnoses the unused local variable in function f() below but misses the unused variable in the explicitly instantiated template g(): $ cat u.C && gcc -S -Wall -Wextra -Wpedantic -Wunused u.C void f () { typedef int T; T t; // warning, ok } template <class T> void g () { T t; // warning, ok typedef T U; U u; // no warning, bug } template void g<int>(); u.C: In function ‘void f()’: u.C:4:5: warning: unused variable ‘t’ [-Wunused-variable] T t; // warning, ok ^ u.C: In instantiation of ‘void g() [with T = int]’: u.C:16:22: required from here u.C:10:5: warning: unused variable ‘t’ [-Wunused-variable] T t; // warning, ok ^