https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98278
Bug ID: 98278 Summary: switch optimisation and -fstrict-enums Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: denis.campredon at gmail dot com Target Milestone: --- Created attachment 49761 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49761&action=edit input file The attached file, compiled with -O2 -fstrict-enums, only for `foobar` all branches are transformed to a jump table. If I did not made any mistake all the function should be able to be transformed should produce the same assembly. Changing the definition of the enum to enum e { A = 1, B, C, D}; will produce worse code. Only one jumtable is used/created. enum e { A = 2, B = 4, C = 6, D = 8 }; (or any other sequence) no jump table is created.