This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
enum's and signedness
- From: Segher Boessenkool <segher at koffie dot nl>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 31 Dec 2002 04:19:25 +0100
- Subject: 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