From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 8VjuNjIjZ2ro4i8AWB0awg (envelope-from ) for ; Mon, 27 Jul 2026 05:21:54 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=b4SDzG3L; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id DC9C41E09E; Mon, 27 Jul 2026 05:21:54 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,WEIRD_PORT autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 0EB051E099 for ; Mon, 27 Jul 2026 05:21:54 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5DF0A4BA2E0A for ; Mon, 27 Jul 2026 09:21:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5DF0A4BA2E0A Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=b4SDzG3L Received: from PH8PR06CU001.outbound.protection.outlook.com (mail-westus3azon11012030.outbound.protection.outlook.com [40.107.209.30]) by sourceware.org (Postfix) with ESMTPS id E16BA4BA2E04 for ; Mon, 27 Jul 2026 09:20:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E16BA4BA2E04 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E16BA4BA2E04 Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=40.107.209.30 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1785144054; cv=pass; b=uv3FFNyMhIl7hBNVMCPj6rsAU8WbwyUdQ5syFnzB+2GtJUS23KKHFhBhJeuRq8lPLqD065ACtFDmtVht+ODL2Usk1ocwnXrA8kUqoMCuT4F2IsR5C0W70p90cZw7deUbq7weD2JgCXDdx91uJhq4TN99Z6Uz87WRgzAtjF9rNeE= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1785144054; c=relaxed/simple; bh=deN/Vm3ejnxTlSmaWO5YEDpZvq4MPQw5+ukt8fWkfaA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hrd+efwzBuNoVBorZ8mYyX19kcv0sqf/nJ4P9LgI7I7G/iJ0e7G559TjaDKjug2AeuB58SJQ6o9vK6vhJ942e7p8V/9+yKJFEPQs2+ZNZhscSX6MTVI9lFRi8PRfH1nqeF3kHRvvy+H20//lj8e1i5rSVfFy3B3QhREu/WtCms0= ARC-Authentication-Results: i=2; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=b4SDzG3L DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E16BA4BA2E04 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZMkN7ABeVL3EpnyrVFkZ9Fdoo33E9NfaECIyqZCifDVxUVd6Yz19vlyZE7KDLQJ6f7tZ695AqhZP5PME5rq7rHyMxTQWYsF1a2d4LBrCRJDuk4TFJMM4I9qSh1CRhrBo1fX4SoFpZMOC+dx3LYZp/c1oUJF2kTZXvg+mx6fnN6y4qZ4OLJ5wGaTao1cMFb5wpscUkXX8aD5DTGAey+eEmLF5F8sNGncEIyIUrk38FkkHSmBhXnFZcoxcAezhUxlST6HppdEyMdToSz9zpPROKWHNd8AonNvpt1XZ9H2SrIZjsLfhIRfQEfezaU8RPLQZYNCIwBw0KF7gl2dQ+2g3ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=09UtBqsxkYY7/mv6cz/jGgYiIFwm8mic1r6P+07P1o4=; b=PhyuOs328T17ZIN5M6Nb4Tg4BGf8nVcHZD2y+txSwdayn9KTRlDXopARPKyokmFUrZFefKZlKCczV0LkIKvdQ748qELy/7P7V+O2vT8dwu/uutg04nCnWL0GU0gtgcEKHYb+Dx1wDzOoqNfdjzlOW0VbGeLa1w9c1+JA+997b+VzXKsV12ONH/zMURpuZBch/MgR1sSKtRAg1Opzqi9Myu0mnNYBZMowU3J+1o0TXE5AW3XQ+795qHCef5vmQpXwTDhvG3923x4VLd2RlCacCfKBB8qwM+uJTZXNnBpkl/Qhd15Z3P4sGnOIO/gcvVQgSVMLmV3eZQePB6lUi/nXeg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=09UtBqsxkYY7/mv6cz/jGgYiIFwm8mic1r6P+07P1o4=; b=b4SDzG3LTPJeEkkmo597hU/e75HuhWTzqYY9aoQ3OTmbUzYYwcSoCnDm0RtYAzM+/l16rqHyOHnf/BOxWK7Fd4iWZO1k9Boi/PeOsN9+Ih/pNJ2Vxd9ZJgg6cmP8hCZrZQWFFaNbl7rVRNoIyOjMURYOu3Spr6X0OfruwvjavSI= Received: from BY3PR10CA0021.namprd10.prod.outlook.com (2603:10b6:a03:255::26) by SJ0PR12MB6904.namprd12.prod.outlook.com (2603:10b6:a03:483::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.13; Mon, 27 Jul 2026 09:20:43 +0000 Received: from CO1PEPF000075F0.namprd03.prod.outlook.com (2603:10b6:a03:255:cafe::44) by BY3PR10CA0021.outlook.office365.com (2603:10b6:a03:255::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.13 via Frontend Transport; Mon, 27 Jul 2026 09:20:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CO1PEPF000075F0.mail.protection.outlook.com (10.167.249.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Mon, 27 Jul 2026 09:20:43 +0000 Received: from rocgdb-taktemur.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Mon, 27 Jul 2026 04:20:41 -0500 From: Tankut Baris Aktemur To: CC: , Subject: [PATCH 2/2] gdb: preserve lhs type's address spaces/classes in check_typedef Date: Mon, 27 Jul 2026 09:20:01 +0000 Message-ID: <20260727092001.1683349-2-tankutbaris.aktemur@amd.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260727092001.1683349-1-tankutbaris.aktemur@amd.com> References: <20260727092001.1683349-1-tankutbaris.aktemur@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075F0:EE_|SJ0PR12MB6904:EE_ X-MS-Office365-Filtering-Correlation-Id: a65cee17-6dfa-4106-5b44-08deebc0555b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|36860700016|23010399003|82310400026|13003099007|56012099006|11063799006|10067099003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: akEckefecOTsm5azZ/BEsFB8RB7XQuXTqioIihxHJ8Hb5dfKOtYQPoDGtKWTe/qEv4EE381E4LQS+a03p5eX/BUDo9cT8UeESsX0BRrclQwZzbuAWU8td6Io+rP2VSDjJM9hK5W3yDFIunQueIE7d0qREUJsdQSaZJpKtfwC4MUmSYQ3TeKxTx3AylZ7beNNMu0tvJPPSCvgGLBPHgfhOBlnhAT5nYT8Y5MoKJBQY+oEnpMQHqR4U5zojIuLWji3T8AUbUq5tbKKc/Oc7BWLxbdnOGGDWyOvUmakMSy5XrkXlsuaOEI+pTMG+LPL9+5uEB9NIjopPW1uGnZ5dz0KsJqTv0o6vfCK3IlU6A/aqNarZVlWh0P80bCycD+MDcTsdOf+5U7ocE539l/C/IOem4r9Efuhs8o7gBsrAF4SVCB4yign7AR7nHuL3p/4afY7v7PdWTfvXyyTtlYHfXzW1/4BOxba2XcTx3szSjeUHeLNNAgBsDKTZMEllk4r0BvtrqI7FrOcAZ5GLTNj38Q3h35qvG03zqcrZn0nDiVQh1FpoHB+MrHerjuJYaSvzxLi5cwwgw1QL4npJw/XPFg1Kbw61us7ktbE6lmwB1sz2FyBbZ5wdnBpdNXavDZTYjhNLeTqsnaH05mwmDgy9l0q8QOeDWL5czkvDE5uf7/Owc4= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(1800799024)(36860700016)(23010399003)(82310400026)(13003099007)(56012099006)(11063799006)(10067099003)(22082099003)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DdH2/QqCnb7WZm1z2Q2G6fCsq/gmzpmO9yvfXEPHZN61zQsy5uL+cFVGehBBigBqbfKtsTX+f3FKk7NOsb1HpjCU4HSdUEf8goyBc9aCced/kc9uF7LW/HpxEcdArkY2yBxmlj5C9uVC0VUUy4aovZg3lMZZhPYzm8K9K65jiluxwByjsasZ20pp1fRpUR4OoXP9iI7iHTJFhtW/1YGvYOP3Ny3hrb6TNH6hzpDHuONkyD4jEmk+vW67u/gRrfYEFZaucjamq+xevcqF9vihqFQ+EqWUWiw10w0DMEsSTjqFFdQYLDIun+awmWuTsx5FjHrhYQ0Z4ZKVDxkTBMezieKWpIAD/smAZMvZcfo2+NGFHpOCKtuFHcNZiWa1d9BVdGKLhFKrMqnVxOfck79qRtgvYU9l7A8QjuKtUgTvkTF5/Lq1POF0DklNi7UgbOHO X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2026 09:20:43.0139 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a65cee17-6dfa-4106-5b44-08deebc0555b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000075F0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6904 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org In commit 92fdad7 "gdb: convert type instance flags to bitfields", `operator|=` of type_instance_flags required the address space and address class values of left-hand-side to be zero. This introduced the following bug (thanks to Keith Seitz for reporting it at https://inbox.sourceware.org/gdb-patches/053e90c0-53f0-4748-9d27-0237b9f21221@redhat.com/T/#u): typedef int myint; (gdb) ptype (@code myint) 3 ../../src/gdb/gdbtypes.h:127: internal-error: operator|=: Assertion `harvard_aspace == 0' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. ----- Backtrace ----- 0x5bb1d1 gdb_internal_backtrace_1 ../../src/gdb/bt-utils.c:122 0x5bb210 _Z22gdb_internal_backtracev ../../src/gdb/bt-utils.c:173 0xdfbbaa internal_vproblem ../../src/gdb/utils.c:434 0xdfbf45 _Z15internal_verrorPKciS0_P13__va_list_tag ../../src/gdb/utils.c:514 0x162763f _Z18internal_error_locPKciS0_z ../../src/gdbsupport/errors.cc:57 0x87e8e6 _ZN19type_instance_flagsoRERKS_ ../../src/gdb/gdbtypes.h:127 0x875d71 _Z13check_typedefP4type ../../src/gdb/gdbtypes.c:3072 The |= operator is used in check_typedef as follows: /* Preserve the instance flags as we traverse down the typedef chain. Handling address spaces/classes is nasty, what do we do if there's a conflict? E.g., what if an outer typedef marks the type as class_1 and an inner typedef marks the type as class_2? This is the wrong place to do such error checking. We leave it to the code that created the typedef in the first place to flag the error. We just pick the outer address space (akin to letting the outer cast in a chain of casting win), instead of assuming "it can't happen". */ { type_instance_flags new_instance_flags = type->instance_flags (); new_instance_flags.harvard_aspace = HARVARD_ASPACE_NONE; new_instance_flags.address_class = 0; instance_flags |= new_instance_flags; } So, the assertion in operator|= was applied on the wrong operand. The outer type, which is the left-hand-side in this case, should preserve its values whereas the right-hand-side should have 0 as its address space and address class values. Fix the bug by updating the assertion. Furthermore, rename operator|= to "merge". Type instance flags are no longer stored as a bitmask value, but rather as a struct. Having an operator like |= gives the wrong impression that we are doing a bitmask OR. Using a method makes the intention clearer. Include a regression test. --- gdb/gdbtypes.c | 2 +- gdb/gdbtypes.h | 14 +++++++------- gdb/testsuite/gdb.cp/typedef-operator.exp | 3 +++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index ad401872941..66c00da389a 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -3065,7 +3065,7 @@ check_typedef (struct type *type) new_instance_flags.harvard_aspace = HARVARD_ASPACE_NONE; new_instance_flags.address_class = 0; - instance_flags |= new_instance_flags; + instance_flags.merge (new_instance_flags); } } diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index eda09641248..f8d7ed5ab91 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -119,21 +119,21 @@ struct type_instance_flags return !(*this == other); } - type_instance_flags &operator|= (const type_instance_flags &other) + /* Merge OTHER flags to THIS, except address spaces and address + classes. Require OTHER's address space and address class to be + zero, and preserve the address space and address class values of + THIS. */ + void merge (const type_instance_flags &other) { is_const = is_const || other.is_const; is_volatile = is_volatile || other.is_volatile; - gdb_assert (harvard_aspace == 0); - harvard_aspace = other.harvard_aspace; - - gdb_assert (address_class == 0); - address_class = other.address_class; + gdb_assert (other.harvard_aspace == HARVARD_ASPACE_NONE); + gdb_assert (other.address_class == 0); is_nottext = is_nottext || other.is_nottext; is_restrict = is_restrict || other.is_restrict; is_atomic = is_atomic || other.is_atomic; - return *this; } /* Constant type. If this is set, the corresponding type has a diff --git a/gdb/testsuite/gdb.cp/typedef-operator.exp b/gdb/testsuite/gdb.cp/typedef-operator.exp index 9513b3725dc..e03502769a4 100644 --- a/gdb/testsuite/gdb.cp/typedef-operator.exp +++ b/gdb/testsuite/gdb.cp/typedef-operator.exp @@ -32,3 +32,6 @@ if {![runto_main]} { } gdb_test "p *v" " = 42" "test typedef" + +# Test that address spaces are preserved. +gdb_test "ptype (@data D)u" "type = @data class C .*" -- 2.53.0