cppfront
cppfront copied to clipboard
[BUG] Initializing an enum array does not compile
trafficstars
I try to compile this simple code:
Color: @enum<u8> type = {
Black: = 0;
White: = 1;
}
main: () = {
colors: std::array<Color, 3> = (Color::Black);
}
The C++ code is generated correctly but I get an error when compiling.
main.cpp2:6:40: error: chosen constructor is explicit in copy-initialization
6 | std::array<Color,3> colors {Color::Black};
| ^~~~~
main.cpp2:12:18: note: explicit constructor declared here
12 | constexpr Color::Color()
| ^
main.cpp2:6:40: note: in implicit initialization of array element 1 with omitted initializer
6 | std::array<Color,3> colors {Color::Black};
| ^
1 error generated.
Here is the code I ran: https://cpp2.godbolt.org/z/MnrPqT4fK