[Bug c++/113153] New: suboptimal error message when using reserved identifier
michael.kenzel at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Dec 27 02:27:49 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113153
Bug ID: 113153
Summary: suboptimal error message when using reserved
identifier
Product: gcc
Version: 13.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: michael.kenzel at gmail dot com
Target Milestone: ---
When using a keyword as the name of an enum, gcc will issue a diagnostic about
the enum being "unnamed". This can be very confusing:
enum class register { rax, rcx, rdx, rbx };
compiled with -std=c++23 produces
error: unnamed scoped enum is not allowed
1 | enum class register {};
| ^~~~~~~~
warning: elaborated-type-specifier for a scoped enum must not use the 'class'
keyword
1 | enum class register {};
| ~~~~ ^~~~~
| -----
error: expected identifier before 'register'
1 | enum class register {};
| ^~~~~~~~
error: expected unqualified-id before '{' token
1 | enum class register {};
| ^
https://godbolt.org/z/s1ocevaWe
More information about the Gcc-bugs
mailing list