This is the mail archive of the gdb@sourceware.org mailing list for the GDB 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]

inconsistency in printing out the value of an unsigned short in gdb


Hi all,

I have a simple program:

typedef unsigned short UInt16;
const UInt16 c_uint16 = 0xFE;
UInt16 g_uint16 = 0xFE;
const unsigned short c_ushort = 0xFE;

int main() {
    printf("c_ushort=%#X\n",c_ushort);
    printf("c_uint16=%#X\n",c_uint16);
    printf("g_uint16=%#X\n",g_uint16);
    return 0;
}
I use  g++ version 4.0 and gdb  version 6.6
g++ -g constants.cpp -o ./constants
running this exec gives the following output as expected
c_ushort=0XFE
c_uint16=0XFE
g_uint16=0XFE
But running it in gdb
gdb ./constants
(gdb) b main
(gdb) p /x c_ushort
$1 = 0xfe
(gdb) p /x g_uint16
$2 = 0xfe
(gdb) p /x c_uint16
$3 = 0xfffe

Weird why does it not print the value 0xfe like the other ones.

When I use gcc-4.0 it works as expected

Any ideas??

Cheers,
   Erik


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