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

--- Comment #10 from Jiri Slaby <jirislaby at gmail dot com> ---
(In reply to Jonathan Wakely from comment #9)
> (In reply to Jiri Slaby from comment #4)
> > Another question is why B is affected by A at all? Also sizeof of that enum
> > (if one gives it a name) is 8 with gcc-13. That is not allowed by the
> > standard, IMO.
> 
> C99, C11, and C17 all say:
> 
> "The expression that defines the value of an enumeration constant shall be
> an integer
> constant expression that has a value representable as an int."
> 
> So enum { A = 0xffffffff } is a constraint violation and not allowed by the
> standard anyway. Such code was always non-conforming and relying on an
> (undocumented?) GCC extension, so the standard has nothing to say about the
> type.

Ah, that's correct. So the question then is: is it a feature we can rely on
(even if undocumented -- can the behavior can be documented in gcc?), or we
should drop enum uses for values > MAX_INT?

Reply via email to