https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60725
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |manu at gcc dot gnu.org --- Comment #3 from Manuel López-Ibáñez <manu at gcc dot gnu.org> --- (In reply to Marek Polacek from comment #1) > It adds the default case at the end of the switch so we can jump over the > whole switch body. But it should do so only if the labels cover the whole > range of the controlling expression of the switch. Here the switch label > seemingly covers the whole range of the enum, but TYPE_MAX_VALUE of the enum > E is UINT_MAX, while the high value of the case label is 0. But in C, e can contain any value of the underlying type (unsigned int). Thus one can legally call f1(10), and then what happens next is probably a bug. enum E { E1=0 }; static inline int f1(enum E e) { switch (e) { case E1: return 1; } } int main () { return f1(10); } If this is actually undefined behavior, -fsanitize=undefined does not seem to catch it.