https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94078
Bug ID: 94078 Summary: bogus and missing -Wmismatched-tags on an instance of a template Product: gcc Version: 10.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: --- The test case below shows GCC gets confused by the declarations of the template instances below: it issues -Wmismatched-tags for the wrong declaration and fails to diagnose the one it's supposed to, and it doesn't issue -Wredundant-tags for either of them. $ cat t.C && gcc -Wall -Wextra -Wmismatched-tags -Wredundant-tags -S t.C template <class> struct S; extern class S<int> si; // missing -Wmismatched-tags extern struct S<int> si; // bogus -Wmismatched-tags t.C:3:15: warning: ‘S<int>’ declared with a mismatched class-key ‘struct’ [-Wmismatched-tags] 3 | extern struct S<int> si; // bogus -Wmismatched-tags | ^~~~~~ t.C:3:15: note: replace the class-key with ‘class’ t.C:2:14: note: ‘S<int>’ first declared as ‘class’ here 2 | extern class S<int> si; // missing -Wmismatched-tags | ^~~~~~ Clang points out the correct declarations: t.C:2:8: warning: class 'S' was previously declared as a struct; this is valid, but may result in linker errors under the Microsoft C++ ABI [-Wmismatched-tags] extern class S<int> si; // missing -Wmismatched-tags ^ t.C:1:25: note: previous use is here template <class> struct S; ^