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

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Julien Blanc from comment #9)
> But i’d expect both checkers to detect such misuse.

No, Nathaniel is correct that there is no UB here, so nothing for the sanitizer
to complain about. The documented behaviour is in terms of "a value outside the
range of values for the enum type" and that's not possible for a scoped enum
type.

> While it could be valid
> code, there’s a high chance that its a bug.

I disagree, but in any case it's certainly not UB.

The purpose of -fsanitize=enum is not to detect loads of values that don't
correspond to any enumerator (because that's not necessarily a bug, and is a
very common idiom in C and C++). It's to detect loads of values that are
undefined because the enum cannot represent those values.

Reply via email to