g++ 2.96 -W issues bogus warning for conditional expression with enum and unsigned

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Thu Jul 6 12:11:00 GMT 2000


> Is there a language lawyer in the house?

I think I can cite one. Core Issue 172, submitted by a guy named
Bjarne Stroustrup, starts

# According to 7.2 dcl.enum paragraph 5, the underlying type of an
# enum is an unspecified integral type, which could potentially be
# unsigned int. The promotion rules in 4.5 conv.prom paragraph 2 say
# that such an enumeration value used in an expression will be
# promoted to unsigned int.

He then proposes than unsigned int should be allowed as underlying
type only when int cannot represent all values, see
http://www.informatik.hu-berlin.de/~loewis/cwg_active.html#172

This would outlaw gcc's current implementation. The issue is still
open, and I'd expect intervention from various vendors (including gcc)
against this specific resolution.

On your original question: It seems you are right; this is a bug in
gcc.

Regards,
Martin


More information about the Gcc-bugs mailing list