From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16772 invoked by alias); 25 Sep 2007 14:10:57 -0000 Received: (qmail 16759 invoked by uid 22791); 25 Sep 2007 14:10:57 -0000 X-Spam-Check-By: sourceware.org Received: from wa-out-1112.google.com (HELO wa-out-1112.google.com) (209.85.146.177) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 25 Sep 2007 14:10:53 +0000 Received: by wa-out-1112.google.com with SMTP id l35so2558139waf for ; Tue, 25 Sep 2007 07:10:52 -0700 (PDT) Received: by 10.115.59.4 with SMTP id m4mr4425009wak.1190729451940; Tue, 25 Sep 2007 07:10:51 -0700 (PDT) Received: by 10.114.158.13 with HTTP; Tue, 25 Sep 2007 07:10:51 -0700 (PDT) Message-ID: Date: Tue, 25 Sep 2007 14:19:00 -0000 From: "Erik Niessen" To: gdb@sourceware.org Subject: inconsistency in printing out the value of an unsigned short in gdb MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-09/txt/msg00202.txt.bz2 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