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

--- Comment #15 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
BTW, if we implement an attribute for this, we should also add -fsanitize=enum
support for it, so that we diagnose whenever one loads a value which is not
named.
clang clearly doesn't implement that, so using the attribute can't be really
checked.

enum __attribute__((enum_extensibility(closed))) E { E1, E2, E3, E32 = 32, E64
= 64, E65 = 65, E257 = 257 };

enum E
foo (enum E *p)
{
  return *p;
}

https://godbolt.org/z/z9P4hPq4x

All that it checks (like GCC which ignores the attribute) that the value loaded
isn't >= 512.

Reply via email to