public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* print char and signed char equally
       [not found] <55A1F108.6030001@yahoo.com>
@ 2015-07-12  8:31 ` xparmenides
  0 siblings, 0 replies; only message in thread
From: xparmenides @ 2015-07-12  8:31 UTC (permalink / raw)
  To: gdb


Hi,
According the manual, " Strings are identified as arrays of char values 
without specified signedness. Arrays of either signed char or unsigned 
char get printed as arrays of 1 byte sized integers. -fsigned-char or 
-funsigned-char gcc options have no effect as gdb defines literal string 
type "char" as char without a sign. For program code

      char var0[] = "A";
      signed char var1[] = "A";

You get during debugging

      (gdb) print var0
      $1 = "A"
      (gdb) print var1
      $2 = {65 'A', 0 '\0'}
"
But, I got a different result:

(gdb) l
1       #include <stdio.h>
2
3       int main(){
4         char var0[] = "A";
5         signed char var1[] = "A";
6         return 0;
7       }
(gdb) print var0
$3 = "A"
(gdb) print var1
$4 = "A"

It seems that print command displays a char the same as a signed char. I 
think the mannual has a bug.




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-07-12  8:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <55A1F108.6030001@yahoo.com>
2015-07-12  8:31 ` print char and signed char equally xparmenides

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).