This is the mail archive of the gcc-bugs@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]

[Bug debug/14328] New: gcc3.2.2 generates incorrect debugging enum values


gcc3.2.2 generates negative values [-128 ... -1] as debugging symbols for enum
entries which have values in the range [128 ... 255]. Therefore attempts to 
view such entries under gdb returns bogus values. The following source file and 
gdb session demonstrate this problem. gcc-2.9.6 doesnt exhibit this behavour.


/* enum_err.c */
#include <stdio.h>
#include <stdlib.h>

typedef enum {
  ENTRY_126 = 126,ENTRY_127,ENTRY_128,ENTRY_129
} entries_t;

int 
main(int argc, char **argv)
{
  entries_t x,y;

  x = ENTRY_127;
  y = ENTRY_128;
  printf("hello world %d %d \n",((entries_t)x==ENTRY_127),(y==ENTRY_128));
  printf("more %x %x \n",ENTRY_127,ENTRY_128);
  return 0;
}

$ gcc -o enum_err enum_err.c -g -Wall
$ gdb enum_err


GNU gdb Red Hat Linux (5.2-2)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) ptype entries_t
type = enum {ENTRY_126 = 126, ENTRY_127, ENTRY_128 = -128, ENTRY_129}
(gdb) p/d ENTRY_127
$1 = 127
(gdb) p/d ENTRY_128
$2 = -128
(gdb) p/d ENTRY_129
$3 = -127
(gdb)

-- 
           Summary: gcc3.2.2 generates incorrect debugging enum values
           Product: gcc
           Version: 3.2.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tjruwase at stanfordalumni dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14328


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