From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id jGUdGa6xrmnChh8AWB0awg (envelope-from ) for ; Mon, 09 Mar 2026 07:40:30 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=oW22syR2; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=oW22syR2; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 465001E0DD; Mon, 09 Mar 2026 07:40:30 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.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 A080E1E08D for ; Mon, 09 Mar 2026 07:40:28 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id EE0D94B9DB41 for ; Mon, 9 Mar 2026 11:40:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EE0D94B9DB41 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=oW22syR2; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=oW22syR2 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11010019.outbound.protection.outlook.com [52.101.84.19]) by sourceware.org (Postfix) with ESMTPS id 16D0E4BA2E24 for ; Mon, 9 Mar 2026 11:39:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 16D0E4BA2E24 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 16D0E4BA2E24 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=52.101.84.19 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1773056397; cv=pass; b=bzjS49K5zoyJxmcRSxDM7AaZsQeZNQ+ArUi98jqBKUzh5Ihgo2o3al4q3VXvKilRaQ7e+0x/lZK4edES1VeXjxCw0VeBqCnOaNaaAhFKWef7wLhmKTE4jg4yzVUtNEdKWTqmFszRFj/Fy5ZtE3bPJL3+Oxzb4d1po4iaTPd7RXY= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1773056397; c=relaxed/simple; bh=eEniD9VzrTTnBUrobvjVua/ugwbMRXs55ojn/V/+YiA=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:Subject:To:From: MIME-Version; b=KZ3o+vYiA4feYbVIX/BxQvOMZdS+wb9LI5FfYZ7m2s/7mGm4oZjJUFDPso/OQIrpPXWg69oAxdjeBpVEcCWzPKkI6nw9QQOk2FgOyD/27T4KKk8MxAmksJ4cDTZtUVPqcfYOM9IZO7vd1PuT4trlu39I9QzprRHmfo5Tg8dKQf4= ARC-Authentication-Results: i=3; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 16D0E4BA2E24 ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=KiiWQp+JVamySp+2woQWrlJC/ASHdua5mYaqZbP7u2wqi31bKw2kKO1D+JI5iulfkXZa0ocQkezuhZZWhhRwJAGbEAdYF7If0NwQykW0nQxPLL8vB0iYzWbPMV9AbygeZWft09KHLpXAd8/NiL6sOPoYS+OcA6woNTdieo/blWB6Mc0whVk/3jQV6IhtkpxbcURJrkJIb921Av0SrX5KfS7AX9vCwjhogJB5jaoDizn9aCtd1NcayqHVH3O+04GYKlWeAVsjxr3oqd8oqP7xcGzP4wLDxXO0ciE4yc844zZ4rvDt7oWNM1cRW85wboErXOt1+9mHCX+C9hAQ7TiyLg== ARC-Message-Signature: i=2; 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=/Z69Tlk4pBlToZq+FhMXb4Bybwl/93XOXfnAba29VOA=; b=O4ER36mepCIUEO47I2I+aWIOj7UExKDLvCNP0M3ZdUeQHafSwHyjcQZTkoGQaYn2Ryc60/gDGSKHVS3ke2lnCudow/qyR//IsU2AWUymUZouJcT3fvuE5YR+7jrI1bBtCV9ieqzgr6xzO2Bmz/H6xQyyn/Ribh4WZZaSklk9wOhdQ384Ce9UcYWLa4Q5LpECswO1f4njuQgroyHxMtMGnqt36pbFdp9OhgNmHgtbp9foE1441WnwxoHCO3O3A0QdEZglL9aKgQq4IQz9PGQykkz6q5l0or1hs4yrQe/JduKiLM0OWn6xRCATrId+FS3Af2a1yQw3RepNix0ReuF38Q== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=tromey.com smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/Z69Tlk4pBlToZq+FhMXb4Bybwl/93XOXfnAba29VOA=; b=oW22syR2d+sMmRpaMDM5WJhMz/qCkgmYh1o1KNmf7szMS23oe8xGogh1WVfk6verAhv6AEjV05hSiqs9UOewS35f7ycE6vDbPI9gj55SD51mIgnpCh6LHwx5DjmR4/NastULR0cDFwwfU3Jb956UjdGiz+hdt+9BWa/gdrnVjFk= Received: from DUZPR01CA0083.eurprd01.prod.exchangelabs.com (2603:10a6:10:46a::19) by DU0PR08MB7881.eurprd08.prod.outlook.com (2603:10a6:10:3b3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9678.25; Mon, 9 Mar 2026 11:39:50 +0000 Received: from DB1PEPF000509EA.eurprd03.prod.outlook.com (2603:10a6:10:46a:cafe::21) by DUZPR01CA0083.outlook.office365.com (2603:10a6:10:46a::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9678.25 via Frontend Transport; Mon, 9 Mar 2026 11:39:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 4.158.2.129) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 4.158.2.129 as permitted sender) receiver=protection.outlook.com; client-ip=4.158.2.129; helo=outbound-uk1.az.dlp.m.darktrace.com; pr=C Received: from outbound-uk1.az.dlp.m.darktrace.com (4.158.2.129) by DB1PEPF000509EA.mail.protection.outlook.com (10.167.242.68) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9654.16 via Frontend Transport; Mon, 9 Mar 2026 11:39:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XLmBWCSi6IYJA/jkSAVL0e/D3jIuoJiciSAU6TFaLIbcEpwmNlhVpXidlfehS0RWlTmpyOutQIwD5ZIZgw5srkxItHdIK/5kZc2HMy4t3CW/VKhCEpQwfEOr/4J4/TZzw0+MHcATexHfoWSvFT+HHK8zmnDVnclf9oqi8we0R56xW18Wbwtjep269dtczt+bKjflgY58mmnKnrOI91OzQ+pp9B705eViG2WCN56GF2Qjikxb0JWW2cftKz1l2e2HJ9MKssSx72vdPDiDMJFYvmkqdJYH4bRlKTRBeUIbuUFF0ozM3ZJ7zzWW5KsYmrzqj4zdypH3A65Wx1KJHzzDXA== 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=/Z69Tlk4pBlToZq+FhMXb4Bybwl/93XOXfnAba29VOA=; b=GQ2n5T9/0Mq3qlEtiCf5IXjSWknblrc2HpF86uSjmmuV0ychaQd+n7nRfUjta1XFbJB5QnW43zmXkHed9H3ZCzLz7urjA283YmYKvSxIoPmouywGICXyPfL41/PG80oOSwSKkgYd8XjryR+npomWFqpHqTfDXpH9JPWmHvWuTf+8Rj/LwysX8VUpty/BObQpZw3gF7nhudXdDkWwHOh761zUt2Z4+g00cv7eBuBwwB1yTbjvJE/llBFd21FWweYT/zIJuK76tMTkOHk/mnptSuGPTdRmk2Fz+6LR5/PRHcgBb1w5bpVAYQbYKRXOuKqL94EtXnEvyBLmsoJ7+7HpBQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/Z69Tlk4pBlToZq+FhMXb4Bybwl/93XOXfnAba29VOA=; b=oW22syR2d+sMmRpaMDM5WJhMz/qCkgmYh1o1KNmf7szMS23oe8xGogh1WVfk6verAhv6AEjV05hSiqs9UOewS35f7ycE6vDbPI9gj55SD51mIgnpCh6LHwx5DjmR4/NastULR0cDFwwfU3Jb956UjdGiz+hdt+9BWa/gdrnVjFk= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from DU0PR08MB8663.eurprd08.prod.outlook.com (2603:10a6:10:401::6) by AS8PR08MB8085.eurprd08.prod.outlook.com (2603:10a6:20b:54a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9678.22; Mon, 9 Mar 2026 11:38:45 +0000 Received: from DU0PR08MB8663.eurprd08.prod.outlook.com ([fe80::f957:cec9:ec8d:7968]) by DU0PR08MB8663.eurprd08.prod.outlook.com ([fe80::f957:cec9:ec8d:7968%6]) with mapi id 15.20.9678.023; Mon, 9 Mar 2026 11:38:45 +0000 Message-ID: <5e6bc6f0-79e7-459c-b396-816d9f48bb0f@arm.com> Date: Mon, 9 Mar 2026 11:38:44 +0000 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 5/9] gdb/python: allow ref_ptr::new_reference to accept subclasses of T To: Tom Tromey Cc: gdb-patches@sourceware.org References: <20260303161659.397427-1-matthieu.longo@arm.com> <20260303161659.397427-6-matthieu.longo@arm.com> <87v7fcrd2x.fsf@tromey.com> <871phwzz01.fsf@tromey.com> Content-Language: en-US From: Matthieu Longo In-Reply-To: <871phwzz01.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P265CA0009.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2ad::12) To DU0PR08MB8663.eurprd08.prod.outlook.com (2603:10a6:10:401::6) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: DU0PR08MB8663:EE_|AS8PR08MB8085:EE_|DB1PEPF000509EA:EE_|DU0PR08MB7881:EE_ X-MS-Office365-Filtering-Correlation-Id: 3b9919e7-9137-49ea-3746-08de7dd092ee x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info-Original: DQCj+F7c0jSqHJNtxpFAEBQehppLcXAaQZcDdj15onfMzz3MCvigs3C0I+yBmT+fW1Xj8SYdBQmOu+ewxqOEAGN5JccQcHwl0Ywwtr3pHChpyhfk+gYe2E7jrcuIB8ie9vVRU3aHj1CFP87Mu63Yk+UuXxIVQAjXD2boHfkhe9ZBQlS2gpZRWmfnifwdKqRYBDvFnGfGs0VxvjQt/OMIb3ALuJe5wQp1FEiaZBzJB9arO8T7oRgvbrKxWddBQU6KsLBwGcZ574niWA4On1p95aBpYChky8O7nh6Emq2gMuGqJdSu9RmmvcOhoZSJ2YCJgBbKZgdw09/4nDqhiIWOHQiGgyvqORoDQ5S4oLrVjnjYnaRq83d7DvO3YrSisBm2846O39OJ7HtbAMEOjEsldDUf5owB3oKk83OWj5akvFInnRBUUt5ZUAnL1HRHhTiA3KykedA8NdGGCh0+WvyZD+rq/P7nfW75nssIJeodOhDjYV6cGvW7uROnpx4mGgFAL4WWt8Sz6T7COGkc9Brbv6pwclkGnX1tmphP75fuR4MRfUVuZEm6vHx0Jz2s7ECd0gxeAY9lxxANWuh0GkFokzbVN+tHQ6p9Y3A5H+8n+PhV+d7mY/TtAV9RmJmYN5NE93OdWfO37vRpOT7zPgvNc+/9wpmLJ2WOvtIay+deDH0+augG+1sn9d/Xe3E84XXXMwXzpsLpniuhLSw9I6v2zxEKRCpCADPRphzwMIKNbAg= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR08MB8663.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(1800799024); DIR:OUT; SFP:1101; X-Exchange-RoutingPolicyChecked: MOg6hHvNVEEZgYSmxgYIx/ZRXH69meyEE7OR2oLNtXo6wHi3uyxHu7WK/HLT5ioQ/Ep83ijDyQr2342ANrbf7Ysra2p8ja1tYH2+UPFrxwXwV0WDPkZVIUc2uxQAPr8bOXsnhXEu+E2sks4JC7NaQWURjm7LvaGe5ciTay03N4g2wcbk8exGlcwxUesyulbohrNrukiFTdZO0/WLaw/2gfj7+CL7tna6Gj3pA2kfhR/HDw1Q+YU6noitw8SrsO7epa4nBtPfsvXrmfT9refjtk6aq18TBxdB1CagHZalbpe75v1AvxoSW1kdccpY1nzimkOLz6NF31BEAF94MUqLzw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8085 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB1PEPF000509EA.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 3e8bc320-b544-45c3-ea60-08de7dd06c12 X-Microsoft-Antispam: BCL:0; ARA:13230040|35042699022|1800799024|14060799003|376014|82310400026|36860700016; X-Microsoft-Antispam-Message-Info: 4ig6JzIQiUKhCR/DsdxbYBAM5Oh6JN6kkbY1uFv8IIgEJ4ruxJQNVunGtWEw35e0H/oCTtgnwI9guSL7Vlxhy6+FHwmBNPtrZnyEzkppZO9milppX7uWrroeg8MAJlwxei+Wvwh9r5A8zOkVsqDecMvlVVqbw1RPXV3eucV42WthggVY0cQ1nRd2arSHCo+G/KpsSAQiZxhZOgZcMdKIlRRnap8kDn4QSmHLR5hmXp6p3sS6u0a+KfVTtoTGi5Qua6jqs8sAcSKwyyDR43Sv4qLbi5jVQBUXSm1LS1ZfXY7a8vQ8G4MgdFVNKmFGLZtkZw44YlR/RLG0TBYfqQfmfJJ6twjZMLodXLHnAXfljDXTHe+yL2zQLu57gj4+ptFR+n4COtBAbR05IteqqwdTsAR/4O4FsmpY+HoHG8/W1sYCNJ005NGijPwxp+QGeok6viGtz5NWAydPEPQZ6RuWpZWkRh0IOy5BIcMYGLMm35SIqp0chHcnMVOD4hxFKZ+YQHtFjcFT0BrIAe1AEbHpAZ67PVcNlnf2TeO+PDuHggkvYyKRLD8ts+GUBTjqOqm15Xa/aJTzE72vbQJzrcnZj/A2HBE6U2GVe2WYlzdLsYpg8DPEtk5ZeziguKx5Af99Nb3lKfBm3NM7hdPDZWTB79/qjzTb8DLj+IrZHomQ5zMeMPWACH8omt6Jvtug5kPaam0QV2tyCsq+dunjeraJj+8xmCF13HDt3Sz11WXbA8hjDk3UDh62lsflXKm8Rg1DyW/BUqcmXY2dgdh5/zuOdQ== X-Forefront-Antispam-Report: CIP:4.158.2.129; CTRY:GB; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:outbound-uk1.az.dlp.m.darktrace.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(35042699022)(1800799024)(14060799003)(376014)(82310400026)(36860700016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fB0IbeA70mLVECIfsnVxCwffnd+r684bc12eDPPZlRgDEs4Y2s19ltr5LjPXQJxkBWoWhYXdUivwmrtLVHbDf7vFmsxb5SHAEopDdzNQkxk+teFGDW8Y2zU4oTktV5qzUnZ08xsCo+DbjRQ8AeP4jkGwNLCmm0s6StfLsiYHRw8QELECZEmNd/kpyNKFgwVXwPS+t7GWsS3jskszystoVmknQc9w+3Ndi7jWRvVGqOoD5rON3wXCYrfjDST5zrFQpCrbpx7WaJ59QWuF6MEAgtAosIP5eORF3gBx0JNNfdQ5XfdOsfb/u1sJhmUOOx6NFTiZOWu6DP+uGzFYI6tHBgN1mTCk67KChfDlKadYxcCGzzn4XanrYEG468XcmeI4vYOzIaLOoHnYZ2g/LOR/K7qnHkJcP48BEO8IPwJwiDh6egZnQfh76A2qNUdvpQNL X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2026 11:39:50.4488 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3b9919e7-9137-49ea-3746-08de7dd092ee X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[4.158.2.129]; Helo=[outbound-uk1.az.dlp.m.darktrace.com] X-MS-Exchange-CrossTenant-AuthSource: DB1PEPF000509EA.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB7881 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 On 06/03/2026 16:47, Tom Tromey wrote: >>>>>> Matthieu Longo writes: > >> After a deeper examination, I am not sure that your series helps much for this patch. > >> * Case 1: return value from the registry. > >> PyObject *result = (PyObject *) cfpy_inferior_corefile_data_key.get (inf); >> if (result != nullptr) >> return gdbpy_ref<>::new_reference (result); > >> If I had gdbpy_borrowed_ref available, I could replace the code above by something like: >> gdbpy_borrowed_ref result = cfpy_inferior_corefile_data_key.get (inf); >> if (result != nullptr) >> return result; /* assuming that gdbpy_ref<> would have a constructor taking gdbpy_borrowed_ref. */ > > Ok, I see. Sorry about that. > > Does the registry need to return a properly-typed one? In my understanding, it does not. I guess you would like to change static const registry::key cfpy_inferior_corefile_data_key; to static const registry::key cfpy_inferior_corefile_data_key; But the only impact of this is removing the cast to (PyObject *). Today we can already write: gdbpy_ref<> result (cfpy_inferior_corefile_data_key.get (inf)); I personally don't like this syntax, and would prefer something like: gdbpy_borrowed<> key, inferior_corefile_deleter>::get (inferior *) const; And then in this function: gdbpy_borrowed<> corefile_obj = cfpy_inferior_corefile_data_key.get (inf); if (corefile_obj != nullptr) return corefile_obj; It seems more natural to me. > Perhaps it can just always return a gdbpy_ref<>. > I am not sure how to do this with the current implementation of registry. Why not using something like an std::unordered_map> ? The only impediment seems to be this clean-up routine setting corefile_object->inferior to nullptr. I am not really understanding why this is required. Could this setting to null be removed completely ? >> * Case 2: registration of the new object in the registry and return the value. > >> gdbpy_ref object >> (PyObject_New (corefile_object, &corefile_object_type)); >> ... >> cfpy_inferior_corefile_data_key.set (inf, object.get ()); >> return gdbpy_ref<>::new_reference (object.release ()); > > Here the release stuff is no longer needed as upcasting works fine: > The release() is not required for upcasting, but keeping the reference counter incremented to count for the instance stored inside the registry. /* Allocation of object via PyObject_New() */ gdbpy_ref object (PyObject_New (corefile_object, &corefile_object_type)); ... /* Save the object in the registry which only holds a raw pointer. If this registry was storing gdbpy_ref<> and set() was supporting both copy and move semantics, using set(const &gdbpy_ref<>) would simplify the code on the return to a simple "return value;". */ cfpy_inferior_corefile_data_key.set (inf, object.get ()); /* Return a new reference. The copy is not sufficient because the gdbpy_ref<> would go out of scope at the end of the function, and the registry would potentially hold a dangling pointer as soon as the return value would go out of scope somewhere in the calling context. */ return gdbpy_ref<>::new_reference (object.release ()); > cfpy_inferior_corefile_data_key.set (...); > return object; > >> However, I am getting further from my original objective, which was only flattening the code for upcoming changes. >> All those improvements seem to me out of scope of my original patch. > > Yeah. It's fine to take small steps and not do too much. If we decide to change the implementation of the registry later to store gdbpy_ref<>, the code should simplify itself. However, as explain before, the replacement of a raw pointer by gdbpy_ref<> does not look trivial. Consequently, I propose to keep the code as it is for now. > So if it's convenient just go ahead; but if you don't mind add a bit of > explanation to the commit message. > If I stick to the original goal of this patch, i.e. allowing ref_ptr::new_reference to accept subclasses of T, it seems to me that the description is clear enough. What would you like to add ? > thanks, > Tom Matthieu