https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107622
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> --- If you use enum with fixed underlying type, then all the values of the underlying type are valid, even with -fstrict-enums. Otherwise namespace std { enum class byte : unsigned char {}; } couldn't work properly. Otherwise, with -fstrict-enums, enum { A, B, C } can have values 0, 1, 2, 3 and without -fstrict-enums all the values of the underlying type. See https://eel.is/c++draft/dcl.enum#8 for more details. So, except for the https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107622#c4 g case where we should have optimized it into constant I don't see any missed optimization here.