https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98031
Bug ID: 98031 Summary: missing the error message of undeclared label Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tangyixuan at mail dot dlut.edu.cn Target Milestone: --- Hi, the following code has two errors. However, gcc only reports the second error while ignoring the first one. $ cat s.cpp template<class T> int fun(T i) { static void* labs[2] = { &&lab1, &&lab2 }; goto *(labs[i==0]); lab1: return 1; labs: return 2; //should report an error return 0; } int main() { return lab1(1); } //error here $ g++ -c s.cpp s.cpp: In function ‘int main()’: s.cpp:12:11: error: ‘lab1’ was not declared in this scope 12 | { return lab1(1); } | $ clang++ -c s.cpp s.cpp:4:38: error: use of undeclared label 'lab2' static void* labs[2] = { &&lab1, &&lab2 }; ^ s.cpp:12:11: error: use of undeclared identifier 'lab1' { return lab1(1); } ^ 2 errors generated.