public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug exp/26519] New: wrong type used when printing value
@ 2020-08-21 14:02 vries at gcc dot gnu.org
2020-08-21 20:22 ` [Bug exp/26519] " tromey at sourceware dot org
2020-08-22 8:10 ` vries at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: vries at gcc dot gnu.org @ 2020-08-21 14:02 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=26519
Bug ID: 26519
Summary: wrong type used when printing value
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: exp
Assignee: unassigned at sourceware dot org
Reporter: vries at gcc dot gnu.org
Target Milestone: ---
Consider the following test-case:
...
$ cat test.c
struct ab
{
int a;
int b;
};
extern void bar (void *p);
extern void foo (struct ab *);
int
main (void)
{
struct ab ab;
struct { float a, b; } f = { 1.1, 2.1 };
bar (&f);
foo (&ab);
return 0;
}
$ cat test2.c
struct ab;
void
foo (struct ab *p)
{
}
$ cat test3.c
struct ab;
extern void bar2(struct ab *);
void
bar (struct ab *p)
{
bar2 (p);
}
$ cat test4.c
struct ab {
float a;
float b;
};
void
bar2 (struct ab *p)
{
}
...
Compiled like this:
...
$ gcc -g test.c test2.c test3.c test4.c
...
When we run to bar and print "*p"
...
$ gdb -batch -iex "set language c" a.out -ex "b bar" -ex run -ex "p *p"
Breakpoint 1 at 0x4004ef: file test3.c, line 8.
Breakpoint 1, bar (p=0x7fffffffdc00) at test3.c:8
8 bar2 (p);
$1 = {a = 1066192077, b = 1074161254}
...
we use the type struct ab from test.c to print *p, which is incorrect.
--
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 exp/26519] wrong type used when printing value
2020-08-21 14:02 [Bug exp/26519] New: wrong type used when printing value vries at gcc dot gnu.org
@ 2020-08-21 20:22 ` tromey at sourceware dot org
2020-08-22 8:10 ` vries at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: tromey at sourceware dot org @ 2020-08-21 20:22 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=26519
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> ---
I don't think gdb has any way to know which one to pick.
It guesses, but maybe it should error instead.
I think there's another bug about making
print * ('test4.c:struct ab' *) p
... work.
--
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 exp/26519] wrong type used when printing value
2020-08-21 14:02 [Bug exp/26519] New: wrong type used when printing value vries at gcc dot gnu.org
2020-08-21 20:22 ` [Bug exp/26519] " tromey at sourceware dot org
@ 2020-08-22 8:10 ` vries at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: vries at gcc dot gnu.org @ 2020-08-22 8:10 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=26519
--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom Tromey from comment #1)
> I don't think gdb has any way to know which one to pick.
Agreed.
> It guesses, but maybe it should error instead.
>
In case of C++, I think guessing is fine due to ODR.
But I think for C, we should indeed error.
Or perhaps, prompt to choose which variant (although you mentioned in PR25769
that you wanted to get rid of those prompts).
> I think there's another bug about making
>
> print * ('test4.c:struct ab' *) p
>
> ... work.
I see. I found PR22718, perhaps that's the one you meant.
--
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:[~2020-08-22 8:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-21 14:02 [Bug exp/26519] New: wrong type used when printing value vries at gcc dot gnu.org
2020-08-21 20:22 ` [Bug exp/26519] " tromey at sourceware dot org
2020-08-22 8:10 ` vries at gcc dot gnu.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).