public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/30457] New: Unexpected sign extension during conversions
@ 2023-05-17 14:49 tuliom at ascii dot art.br
2023-05-17 15:42 ` [Bug gdb/30457] " tromey at sourceware dot org
2023-05-17 16:24 ` schwab@linux-m68k.org
0 siblings, 2 replies; 3+ messages in thread
From: tuliom at ascii dot art.br @ 2023-05-17 14:49 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30457
Bug ID: 30457
Summary: Unexpected sign extension during conversions
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: tuliom at ascii dot art.br
Target Milestone: ---
Reproducer:
$ cat test-gdb-print.c
#include <stdio.h>
int
main()
{
unsigned long foo = 0x00007fffffffe8f8;
unsigned long * bar = &foo;
printf("*bar = 0x%lx\n", *bar);
return 0;
}
$ gcc -g test-gdb-print.c
$ gdb a.out
>>> b test-gdb-print.c:9
Breakpoint 1 at 0x401144: file test-gdb-print.c, line 9.
>>> r
>>> p /x *bar
$1 = 0x7fffffffe8f8 <--- OK, this is what we expect.
>>> p /x bar
$2 = 0x7fffffffda40
>>> p /x (unsigned long) *0x7fffffffda40
$3 = 0xffffffffffffe8f8 <--- The value got sign extended.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug gdb/30457] Unexpected sign extension during conversions
2023-05-17 14:49 [Bug gdb/30457] New: Unexpected sign extension during conversions tuliom at ascii dot art.br
@ 2023-05-17 15:42 ` tromey at sourceware dot org
2023-05-17 16:24 ` schwab@linux-m68k.org
1 sibling, 0 replies; 3+ messages in thread
From: tromey at sourceware dot org @ 2023-05-17 15:42 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30457
Tom Tromey <tromey at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org
--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
>>> p /x (unsigned long) *0x7fffffffda40
gdb assumes that if you use "*" on an integer, it's a pointer-to-int.
Maybe arguably a cast on such a dereference should imply a
different pointer type.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug gdb/30457] Unexpected sign extension during conversions
2023-05-17 14:49 [Bug gdb/30457] New: Unexpected sign extension during conversions tuliom at ascii dot art.br
2023-05-17 15:42 ` [Bug gdb/30457] " tromey at sourceware dot org
@ 2023-05-17 16:24 ` schwab@linux-m68k.org
1 sibling, 0 replies; 3+ messages in thread
From: schwab@linux-m68k.org @ 2023-05-17 16:24 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30457
--- Comment #2 from Andreas Schwab <schwab@linux-m68k.org> ---
You can use {unsigned long}0x7fffffffda40 to combine the pointer cast with the
dereference.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-17 16:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-17 14:49 [Bug gdb/30457] New: Unexpected sign extension during conversions tuliom at ascii dot art.br
2023-05-17 15:42 ` [Bug gdb/30457] " tromey at sourceware dot org
2023-05-17 16:24 ` schwab@linux-m68k.org
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).