https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98804
Bug ID: 98804 Summary: GCC misparses template in pack expansion as comparison Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: foom at fuhm dot net CC: richard-gccbugzilla at metafoo dot co.uk Target Milestone: --- GCC parses the following program (by Richard Smith) as `g` less-than `a` greater-than `(a)` instead of a call to the function `g` with template-args `a`, and argument-list `(a)`. And thus, it fails to compile. (Compile with -std=c++20) ---- struct X { constexpr X(int&) {} }; template<class F> void g(F); template<X> void g(int); void g(...); template<class ...A> auto h(A ...a)->decltype (g (0, g < a > (a) ...)) { } void test () { h(0); } ----- I originally noticed this bug with the following test from Clang's test-suite, while working on a mangling bug in Clang. In this original test-case, GCC does successfully compile, but the mangling is weird, exposing that the same misparse occurred. ---- namespace pr30440 { template<class F> void g(F); template<class ...A> auto h(A ...a)->decltype (g (0, g < a > (a) ...)) { } void pr30440_test () { h(); } } ---- GCC mangles as: _ZN7pr304401hIJEEEDTcl1gLi0Espgtlt1gfp_fp_EEDpT_ ^^^^ with greater/less operators in the mangling. But it should've been: _ZN7pr304401hIJEEEDTcl1gLi0Espcl1gIXfp_EEfp_EEEDpT_ ^^^^^^^ with a template-arg.