https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95723
Bug ID: 95723 Summary: GCC get confused while parsing a code Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: haoxintu at gmail dot com Target Milestone: --- This code test.cc, GCC might get confused in parsing. $cat test.cc template <a> friend foo ( decltype (b=c $g++-trunk -w test.cc test.cc:1:12: error: ‘a’ has not been declared 1 | template <a>friend foo( decltype (b=c | ^ test.cc:1:14: error: ‘friend’ used outside of class 1 | template <a>friend foo( decltype (b=c | ^~~~~~ | ------ test.cc:1:36: error: ‘b’ was not declared in this scope 1 | template <a>friend foo( decltype (b=c | ^ test.cc:1:36: error: ‘b’ was not declared in this scope test.cc:1:38: error: ‘c’ was not declared in this scope 1 | template <a>friend foo( decltype (b=c | ^ test.cc:2: error: expected ‘,’ or ‘...’ at end of input test.cc:1:39: error: expected ‘)’ at end of input 1 | template <a>friend foo( decltype (b=c | ~ ^ | ) test.cc:2: error: expected initializer at end of input $g++-10 -w test.cc test.cc:1:12: error: ‘a’ has not been declared 1 | template <a>friend foo( decltype (b=c | ^ test.cc:1:14: error: ‘friend’ used outside of class 1 | template <a>friend foo( decltype (b=c | ^~~~~~ | ------ test.cc:1:36: error: ‘b’ was not declared in this scope 1 | template <a>friend foo( decltype (b=c | ^ test.cc:1:36: error: ‘b’ was not declared in this scope test.cc:1:38: error: ‘c’ was not declared in this scope 1 | template <a>friend foo( decltype (b=c | ^ test.cc:1:36: error: ‘b’ was not declared in this scope 1 | template <a>friend foo( decltype (b=c | ^ test.cc:1:36: error: ‘b’ was not declared in this scope test.cc:1:38: error: ‘c’ was not declared in this scope 1 | template <a>friend foo( decltype (b=c | ^ test.cc:1:36: error: ‘b’ was not declared in this scope 1 | template <a>friend foo( decltype (b=c | ^ test.cc:1:36: error: ‘b’ was not declared in this scope test.cc:1:38: error: ‘c’ was not declared in this scope 1 | template <a>friend foo( decltype (b=c | ^ test.cc:1:21: error: ISO C++ forbids declaration of ‘foo’ with no type [-fpermissive] 1 | template <a>friend foo( decltype (b=c | ^~~ test.cc:1:36: error: ‘b’ was not declared in this scope 1 | template <a>friend foo( decltype (b=c | ^ test.cc:1:36: error: ‘b’ was not declared in this scope test.cc:1:38: error: ‘c’ was not declared in this scope 1 | template <a>friend foo( decltype (b=c | ^ test.cc:1:39: error: expected ‘)’ at end of input 1 | template <a>friend foo( decltype (b=c | ~ ~^ | ) test.cc:1:26: error: expected primary-expression before ‘decltype’ 1 | template <a>friend foo( decltype (b=c | ^~~~~~~~~~~~~ test.cc:1:39: error: expected ‘;’ at end of input 1 | template <a>friend foo( decltype (b=c | ~~~~~~~~~~~~~^ | ; I am sure that some error messages in GCC-10 are duplicated. I am also wondering why GCC-trunk emits "error: expected initializer at end of input", that's so confusing.