Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* inconsistency in printing out the value of an unsigned short in gdb
@ 2007-09-25 14:19 Erik Niessen
  2007-09-25 15:57 ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Erik Niessen @ 2007-09-25 14:19 UTC (permalink / raw)
  To: 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


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

end of thread, other threads:[~2007-09-27 12:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-25 14:19 inconsistency in printing out the value of an unsigned short in gdb Erik Niessen
2007-09-25 15:57 ` Daniel Jacobowitz
2007-09-26  8:33   ` Erik Niessen
2007-09-26 21:38     ` Daniel Jacobowitz
2007-09-27 11:27       ` Erik Niessen
2007-09-27 12:15         ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox