https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91351
Bug ID: 91351 Summary: -fstrict-enums generates incorrect code Product: gcc Version: 9.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: fiesh at zefix dot tv Target Milestone: --- The following code results in different runtime behavior depending on whether it is compiled with -fstrict-enums or not: #include <iostream> enum E { e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25 }; void g() { std::cout << "e11 || e12 || e13\n"; } void j() { std::cout << "default\n"; } void f(E e) { switch (e) { case e11: case e12: case e13: g(); break; case e24: break; case e14: case e15: break; default: j(); break; } } int main() { volatile const E e{e3}; f(e); } (The volatile is necessary to prevent optimization.) Without -fstrict-enums: "default" With -fstrict-enums: "e11 || e12 || e13" Bisecting this behavior says the first bad commit is 37db4f8d72cfc87716a729b38aa2f42097cdbf1f Also see https://godbolt.org/z/NmlKXq for the generated assembly.