public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "bugmenot at mailinator dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug python/28647] New: Python pretty-printer doesn't work with std::variant containing local type
Date: Sat, 04 Dec 2021 01:53:51 +0000	[thread overview]
Message-ID: <bug-28647-4717@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 28647
           Summary: Python pretty-printer doesn't work with std::variant
                    containing local type
           Product: gdb
           Version: 10.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: python
          Assignee: unassigned at sourceware dot org
          Reporter: bugmenot at mailinator dot com
  Target Milestone: ---

When I compile this program:

```
#include <variant>
#include <vector>

struct G {
    int x;
};

int main() {
    struct A {
        int x;
    };
    A a;
    std::variant<A> b {a};
    std::vector<A> c {a};
    std::variant<G> d {G {}};

    __builtin_trap();
}
```

Then run it in gdb, note that `print b` prints

```
std::variant<> [no contained value]
```

but `print d` prints

```
std::variant<G> [index 0] = {{x = 0}}
```

In the first case the print is wrong.

It's caused by `Type.template_argument` function: If this is called in the
Python shell

```
>>> gdb.lookup_symbol("b")[0].type.template_argument(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: syntax error
```

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

             reply	other threads:[~2021-12-04  1:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-04  1:53 bugmenot at mailinator dot com [this message]
2021-12-04 20:27 ` [Bug python/28647] " ssbssa at sourceware dot org
2022-01-05 16:26 ` ssbssa at sourceware dot org
2024-06-24 17:51 ` ssbssa at sourceware dot 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-28647-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).