https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119895
Bug ID: 119895
Summary: List initialization of bitfield enum class member
fails
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: vittorio.romeo at outlook dot com
Target Milestone: ---
Consider the following code:
enum class E : int { eA };
struct S { E i : 2; };
S f() { return {.i = E::eA}; }
Clang accepts the code, while GCC fails with:
error: could not convert '{E::eA}' from '<brace-enclosed initializer list>'
to 'S'
3 | S f() { return {.i = E::eA}; }
| ^
| |
| <brace-enclosed initializer list>
Live example on Compiler Explorer:
- https://gcc.godbolt.org/z/a33rcxhbf