https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98142
--- Comment #2 from Barry Revzin <barry.revzin at gmail dot com> --- That is a great point. I guess in general this is kind of a scary optimization, since it doesn't seem like it's really a global thing? Perhaps this calls for an attribute? [[gnu::i_promise_on_penalty_of_ub_that_only_these_values_are_used]] enum class E : unsigned int { A, B, C, D }; Or, you know, [[gnu::strict_enum]] or something.