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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #1)
> - If you add a large enumerator so that the range of valid values is
> increased, there are no surprises:
> 
>   enum E { A, B, _max = -1u };  // (e < 0) and f(e) promote to unsigned now

Alternatively, give it a negative enumerator to make the underlying type
signed:

  enum E { A, B, _min = INT_MIN };

This will still promote to int, but it also causes GCC to choose int as the
underlying type so there are no surprises (and no warnings for (long long)e <
0).

Based on the reasoning above (i.e. for enum E { A,B } the C++ standard requires
promotion to int irrespective of the compiler's choice of underlying type) I'm
going to close this as not a bug.

Reply via email to