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

Roman Lebedev <lebedev.ri at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |c++

--- Comment #2 from Roman Lebedev <lebedev.ri at gmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> >The `a` can only have value `a::b`,
> 
> NO, it has a full range of the underlying type. For GCC, see
> https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Structures-unions-enumerations-
> and-bit-fields-implementation.html#Structures-unions-enumerations-and-bit-
> fields-implementation
> 
> "Normally, the type is unsigned int if there are no negative values in the
> enumeration, otherwise int. If -fshort-enums is specified, then if there are
> negative values it is the first of signed char, short and int that can
> represent all the values, otherwise it is the first of unsigned char,
> unsigned short and unsigned int that can represent all the values.
> 
> On some targets, -fshort-enums is the default; this is determined by the ABI.
> 
> "

Is this situation different in C++? looks like i set the component wrong.
Is this implementation-defined behavior,
or are you saying that clang is wrong here?

At run time, `a` can not have any other value other than `a::b`:
https://godbolt.org/z/hnc665755
so this really does seem like a bug.

Reply via email to