public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/28681] New: Wrong pretty-printed unique_ptr value when using "finish"
@ 2021-12-10 17:02 simark at simark dot ca
  2021-12-12 17:05 ` [Bug gdb/28681] " ssbssa at sourceware dot org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: simark at simark dot ca @ 2021-12-10 17:02 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=28681

            Bug ID: 28681
           Summary: Wrong pretty-printed unique_ptr value when using
                    "finish"
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: simark at simark dot ca
  Target Milestone: ---

With this program:

---
#include <memory>

std::unique_ptr<int> foo()
{
  int *p = new int (0x1234);
  printf("In foo: %p\n", p);
  return std::unique_ptr<int> (p);
}

int main()
{
  auto ptr = foo ();
  printf("In main: %p\n", ptr.get());
  return 0;
}

---

$ ./gdb -q -iex "add-auto-load-safe-path /usr/share/gdb/auto-load" -iex
"add-auto-load-scripts-directory /usr/share/gdb/auto-load" -nx
--data-directory=data-directory a.out
Reading symbols from a.out...
(gdb) b foo
Breakpoint 1 at 0x11d9: file test.cpp, line 5.
(gdb) r
Starting program: /home/smarchi/build/binutils-gdb/gdb/a.out 

Breakpoint 1, foo () at test.cpp:5
5         int *p = new int (0x1234);
(gdb) finish
Run till exit from #0  foo () at test.cpp:5
In foo: 0x55555556aeb0
main () at test.cpp:13
13        printf("In main: %p\n", ptr.get());
Value returned is $1 = std::unique_ptr<int> = {get() = 0x7fffffffe130}
(gdb) n
In main: 0x55555556aeb0
14        return 0;
(gdb) p ptr
$2 = std::unique_ptr<int> = {get() = 0x55555556aeb0}


Notice how the value printed by finish doesn't match all other three printed
values.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-11-14 21:23 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-10 17:02 [Bug gdb/28681] New: Wrong pretty-printed unique_ptr value when using "finish" simark at simark dot ca
2021-12-12 17:05 ` [Bug gdb/28681] " ssbssa at sourceware dot org
2021-12-13 16:37 ` aburgess at redhat dot com
2021-12-13 16:50 ` aburgess at redhat dot com
2021-12-13 17:31 ` aburgess at redhat dot com
2021-12-13 18:22 ` simark at simark dot ca
2021-12-14  9:50 ` aburgess at redhat dot com
2021-12-14 13:52 ` simark at simark dot ca
2021-12-15 17:39 ` aburgess at redhat dot com
2021-12-23 12:15 ` cvs-commit at gcc dot gnu.org
2021-12-23 12:16 ` aburgess at redhat dot com
2021-12-23 13:05 ` simon.marchi at polymtl dot ca
2022-03-14 10:39 ` cvs-commit at gcc dot gnu.org
2022-11-14 21:23 ` cvs-commit 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).