https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116584
Bug ID: 116584 Summary: Type/value mismatch confuses error recovery Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: blubban at gmail dot com Target Milestone: --- template<typename T> struct foo; void* bar() { return (decltype(foo<5>)*)5; } No flags needed. Result: <source>: In function 'void* bar()': <source>:5:31: error: type/value mismatch at argument 1 in template parameter list for 'template<class T> struct foo' 5 | return (decltype(foo<5>)*)5; | ^ <source>:5:31: note: expected a type, got '5' <source>:5:17: error: expected primary-expression before 'decltype' 5 | return (decltype(foo<5>)*)5; | ^~~~~~~~~~~~~~~~ <source>:5:17: error: expected ')' before 'decltype' 5 | return (decltype(foo<5>)*)5; | ~^~~~~~~~~~~~~~~~ | ) Compiler returned: 1 Expected: Just the first error, the last one looks like it's telling me to write return (); Diagnostics are even funnier if colored - in the last one, the first letter of decltype is red, while the ecltype is green. https://godbolt.org/z/7bcazrPsY