public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "simark at simark dot ca" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/28681] New: Wrong pretty-printed unique_ptr value when using "finish"
Date: Fri, 10 Dec 2021 17:02:54 +0000	[thread overview]
Message-ID: <bug-28681-4717@http.sourceware.org/bugzilla/> (raw)

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.

             reply	other threads:[~2021-12-10 17:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-10 17:02 simark at simark dot ca [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-28681-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).