This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

enum's and signedness


Hi,

GCC makes enumeration types unsigned unless one or more of the
enumerators is negative.  This leads to warnings in cases like:

	enum foobar { foo, bar };
	enum foobar e = some_condition ? foo : bar;

as e is unsigned but the expression is signed (enumerators are
always signed).

Why does GCC choose unsigned over signed here?  Can this
behaviour be changed without breaking ABI's?  It's not documented
in the GCC manual as far as I can see.

This is a fairly common construct in GCC itself, and the cause
of (estimated) about half of the signed/unsigned comparisons
warnings during bootstrap.


Segher



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]