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.