This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug exp/8156] GNU/Linux, gcc, C, enum
- From: "tromey at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: 3 Jan 2009 02:35:29 -0000
- Subject: [Bug exp/8156] GNU/Linux, gcc, C, enum
- References: <20030212003800.8156.daniel.vallstrom@safelogic.se>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- Additional Comments From tromey at redhat dot com 2009-01-03 02:35 -------
I believe that this is actually the correct behavior.
In the source, the expression that defines the value of an enumeration
constant must be representable as an int.
However, the type of the enumeration itself is implementation-defined,
and must only be compatible with char, a signed integer type, or an
unsigned integer type (C99 6.7.2.2).
GCC (info "(gcc)Structures, unions, enumerations, and bit-fields")
defines the type as:
Normally, the type is `unsigned int' if there are no negative
values in the enumeration, otherwise `int'. If `-fshort-enums' is
specified, then if there are negative values it is the first of
`signed char', `short' and `int' that can represent all the
values, otherwise it is the first of `unsigned char', `unsigned
short' and `unsigned int' that can represent all the values.
On some targets, `-fshort-enums' is the default; this is
determined by the ABI.
In the example program, the enum has no negative values, so GCC chooses
unsigned int. When I modify the program to read "firstEnumMember =-1",
gdb correspondingly changes:
(gdb) ptype firstEnumMember+0
type = int
I did not test the -fshort-enums case.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |INVALID
http://sourceware.org/bugzilla/show_bug.cgi?id=8156
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.