From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from outbound-ss-820.bluehost.com (outbound-ss-820.bluehost.com [69.89.24.241]) by sourceware.org (Postfix) with ESMTPS id 90504385B505 for ; Fri, 23 Dec 2022 19:58:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 90504385B505 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway2.mail.pro1.eigbox.com (Postfix) with ESMTP id 4E2461004890F for ; Fri, 23 Dec 2022 19:58:17 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id 8oBNpfhCI9rmy8oBNpLO3A; Fri, 23 Dec 2022 19:58:17 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=a5L1SWeF c=1 sm=1 tr=0 ts=63a60859 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=sHyYjHe8cH0A:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=CCpqsmhAAAAA:8 a=711sYcTENyr4sKvay3MA:9 a=ul9cdbp4aOFLsgKbc677:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=gxFwh1V5gpV8HZnC3R/xUCiqQBG/bklP0wj9RNzue5Q=; b=RuThk//jmsk2po1oQ/Ix/2lxEl VX7QhH+BKTV0H8aEPpVsnXqsAXHTGbHqFy9RVeD0wDyDh/rxpV5gN8AA7hPV9omvpxQof3z/KW43n nn93SEN26Q9NcU6G5/3DwiDTu; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:44806 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1p8oBN-001DwV-0s; Fri, 23 Dec 2022 12:58:17 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Fix crash with C++ qualified names Date: Fri, 23 Dec 2022 12:58:09 -0700 Message-Id: <20221223195809.602699-1-tom@tromey.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.76.186 X-Source-L: No X-Exim-ID: 1p8oBN-001DwV-0s X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:44806 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3028.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 --- 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 d0a4a16ceb5..3757028b4a3 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -1300,6 +1300,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 5d0d2f88b6e..65b33e89a79 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" -- 2.38.1