public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug exp/8156] GNU/Linux, gcc, C, enum
       [not found] <20030212003800.8156.daniel.vallstrom@safelogic.se>
@ 2009-01-03  2:29 ` tromey at redhat dot com
  2009-01-03  2:35 ` tromey at redhat dot com
  1 sibling, 0 replies; 2+ messages in thread
From: tromey at redhat dot com @ 2009-01-03  2:29 UTC (permalink / raw)
  To: gdb-prs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at sourceware dot|tromey at redhat dot com
                   |org                         |


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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug exp/8156] GNU/Linux, gcc, C, enum
       [not found] <20030212003800.8156.daniel.vallstrom@safelogic.se>
  2009-01-03  2:29 ` [Bug exp/8156] GNU/Linux, gcc, C, enum tromey at redhat dot com
@ 2009-01-03  2:35 ` tromey at redhat dot com
  1 sibling, 0 replies; 2+ messages in thread
From: tromey at redhat dot com @ 2009-01-03  2:35 UTC (permalink / raw)
  To: gdb-prs


------- 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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-01-03  2:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20030212003800.8156.daniel.vallstrom@safelogic.se>
2009-01-03  2:29 ` [Bug exp/8156] GNU/Linux, gcc, C, enum tromey at redhat dot com
2009-01-03  2:35 ` tromey at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).