[Bug middle-end/82404] Unnecessary instructions in switch table

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Oct 3 09:15:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82404

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Clang's transformation is not based on the valid values of the enumeration, but
the fact that there's a missing return statement, so if you call it with an
argument that isn't one of the cases it's UB. The compiler can assume that
never happens, so can add an implicit __builtin_unreachable() after the switch.


More information about the Gcc-bugs mailing list