From: "Erik Niessen" <erik.niessen@gmail.com>
To: gdb@sourceware.org
Subject: inconsistency in printing out the value of an unsigned short in gdb
Date: Tue, 25 Sep 2007 14:19:00 -0000 [thread overview]
Message-ID: <f21fe8a50709250710i75147c23o5015a81e3a470a78@mail.gmail.com> (raw)
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
next reply other threads:[~2007-09-25 14:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-25 14:19 Erik Niessen [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f21fe8a50709250710i75147c23o5015a81e3a470a78@mail.gmail.com \
--to=erik.niessen@gmail.com \
--cc=gdb@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox