[Bug c++/98804] GCC misparses template in pack expansion as comparison

2021-02-11 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98804

Marek Polacek  changed:

   What|Removed |Added

   Last reconfirmed||2021-02-12
 CC||mpolacek at gcc dot gnu.org
 Status|UNCONFIRMED |NEW
 Ever confirmed|0   |1

--- Comment #2 from Marek Polacek  ---
Confirmed.

[Bug c++/98804] GCC misparses template in pack expansion as comparison

2021-01-24 Thread richard-gccbugzilla at metafoo dot co.uk via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98804

--- Comment #1 from Richard Smith  ---
Somewhat more reduced:

struct X { constexpr X(int&) {} };
template struct Y {};

int a;
auto h(int b) -> Y; // #1
auto h(int b) -> Y; // #2

GCC accepts #1, but for #2 it produces seven (!) error messages:

:6:21: error: template argument 1 is invalid
6 | auto h(int b) -> Y;
  | ^
:6:21: error: template argument 1 is invalid
:6:21: error: template argument 1 is invalid
:6:21: error: template argument 1 is invalid
:6:18: error: invalid template-id
6 | auto h(int b) -> Y;
  |  ^
:6:21: error: use of parameter outside function body before '>' token
6 | auto h(int b) -> Y;
  | ^
:6:6: error: deduced class type 'Y' in function return type
6 | auto h(int b) -> Y;
  |  ^
:2:20: note: 'template > struct Y' declared here
2 | template struct Y {};
  |^

As far as I'm aware, both #1 and #2 are valid. (I think the "use of parameter
outside function body" restriction is referring to [dcl.fct.default]/9, but
that refers only to uses of parameters within default arguments, not uses in
other contexts in the function declaration.)