https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121330
Bug ID: 121330 Summary: g++ hangs after compilation error in deeply nested template Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jirehguo at tju dot edu.cn Target Milestone: --- The following code causes both Clang and GCC to produce an error due to the undeclared identifier 'func'. However, there is a critical difference in behavior: Clang: Prints the error and exits immediately. GCC: Prints the error but then hangs, failing to terminate. Repro: https://godbolt.org/z/dfEf55318 Code: template <typename... Ts> struct Foo { template <typename... T> static void ignore() { func(); } Foo() { ignore<Ts...>(); } }; struct Base { Base(); ~Base(); }; #define STAMP(thiz, prev) \ using thiz = Foo<prev, prev, prev, prev, prev, prev, prev, prev, prev, prev, \ prev, prev, prev, prev, prev, prev, prev, prev, prev, prev, \ prev, prev, prev, prev, prev, prev, prev, prev, prev>; STAMP(A, Base); STAMP(B, A); STAMP(C, B); STAMP(D, C); STAMP(E, D); STAMP(F, E); STAMP(G, F); int main() { G g; }