This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
print char and signed char equally
- From: xparmenides <xparmenides at yahoo dot com>
- To: gdb at sourceware dot org
- Date: Sun, 12 Jul 2015 16:31:56 +0800
- Subject: print char and signed char equally
- Authentication-results: sourceware.org; auth=none
- References: <55A1F108 dot 6030001 at yahoo dot com>
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.