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

--- Comment #9 from Halalaluyafail3 <luigighiron at gmail dot com> ---
(In reply to uecker from comment #8)
> No, it has to make a decision and document it. For GCC this is here:
> 
> https://gcc.gnu.org/onlinedocs/gcc/Types-implementation.html
C23 defines implementation-defined behavior as "unspecified behavior where each
implementation documents how the choice is made", so it just has to document
how the choice is made not which choice is made. Furthermore,
implementation-defined value is defined as "unspecified value where each
implementation documents how the choice is made". So I don't see how "If one
type is an enumerated type and the other is an integer type other than an
enumerated type, it is implementation-defined whether or not the composite type
is an enumerated type." can be interpreted to require that it has to be chosen
consistently for all enumerated types.

An example of when GCC doesn't choose the same result consistently is when
right shifting a negative integer: "The result of E1 >> E2 is E1 right-shifted
E2 bit positions. If E1 has an unsigned type or if E1 has a signed type and a
nonnegative value, the value of the result is the integral part of the quotient
of E1/2^E2. If E1 has a signed type and a negative value, the resulting value
is implementation-defined." Here GCC doesn't choose the same value consistently
so expressions such as -4>>1 and -2>>1 result in different values.

Reply via email to