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

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).