public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Fix crash with C++ qualified names Date: Mon, 9 Jan 2023 19:27:19 +0000 (GMT) [thread overview] Message-ID: <20230109192719.48920385842E@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bf716a53bd8f725975979397b3c6b9d4bd4434ef commit bf716a53bd8f725975979397b3c6b9d4bd4434ef Author: Tom Tromey <tom@tromey.com> Date: Fri Dec 23 12:55:10 2022 -0700 Fix crash with C++ qualified names PR c++/29503 points out that something like "b->Base::member" will crash when 'b' does not have pointer type. This seems to be a simple oversight in eval_op_member. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29503 Reviewed-By: Bruno Larsen <blarsen@redhat.com> Diff: --- gdb/eval.c | 2 ++ gdb/testsuite/gdb.cp/ambiguous.exp | 1 + 2 files changed, 3 insertions(+) diff --git a/gdb/eval.c b/gdb/eval.c index 05e35941101..bb42e693b17 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -1309,6 +1309,8 @@ eval_op_member (struct type *expect_type, struct expression *exp, case TYPE_CODE_MEMBERPTR: /* Now, convert these values to an address. */ + if (check_typedef (value_type (arg1))->code () != TYPE_CODE_PTR) + arg1 = value_addr (arg1); arg1 = value_cast_pointers (lookup_pointer_type (TYPE_SELF_TYPE (type)), arg1, 1); diff --git a/gdb/testsuite/gdb.cp/ambiguous.exp b/gdb/testsuite/gdb.cp/ambiguous.exp index b430b039887..966d99ae595 100644 --- a/gdb/testsuite/gdb.cp/ambiguous.exp +++ b/gdb/testsuite/gdb.cp/ambiguous.exp @@ -123,6 +123,7 @@ with_test_prefix "all fields" { gdb_test "print n.A1::y" " = 2" gdb_test "print n.A2::x" " = 3" gdb_test "print n.A2::y" " = 4" + gdb_test "print n->A2::y" " = 4" gdb_test "print n.w" " = 5" gdb_test "print n.r" " = 6" gdb_test "print n.z" " = 7"
reply other threads:[~2023-01-09 19:27 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230109192719.48920385842E@sourceware.org \ --to=tromey@sourceware.org \ --cc=gdb-cvs@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: linkBe 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).