https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82299
Bug ID: 82299 Summary: -Wuseless-cast errors on typed enums used in member data initializers in c++1z Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: matt at godbolt dot org Target Milestone: --- The follow code: ``` // compile with -Wuseless-cast -std=c++1z enum Enum : char { A = 0, B = 1 }; struct S { Enum e { Enum::A }; }; ``` Compiled with `-Wuseless-cast -std=c++1z` yields the following erroneous warning: ``` 5 : <source>:5:20: warning: useless cast to type 'enum class Enum' [-Wuseless-cast] Enum e { Enum::A }; ^ ``` This only happens if the `enum` is typed (e.g. the `char` above), and it's compiled with std=c++1z. Seems to have been introduced in GCC 7, still present in trunk. (see https://godbolt.org/g/ehKEau )