From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 9LkpD4BwvmqUDCQAWB0awg (envelope-from ) for ; Thu, 01 Oct 2026 10:38:56 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=vrany.io header.i=@vrany.io header.a=rsa-sha256 header.s=protonmail header.b=AE+ti9na; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 27DB31E051; Thu, 01 Oct 2026 10:38:56 -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 9EA9E1E01F for ; Thu, 01 Oct 2026 10:38:52 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3A9E84BA798A for ; Thu, 1 Oct 2026 14:38:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A9E84BA798A Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=vrany.io header.i=@vrany.io header.a=rsa-sha256 header.s=protonmail header.b=AE+ti9na Received: from mail-4396.protonmail.ch (mail-4396.protonmail.ch [185.70.43.96]) by sourceware.org (Postfix) with ESMTPS id AF35A4BA79BE for ; Thu, 1 Oct 2026 14:38:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AF35A4BA79BE Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=vrany.io Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrany.io ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AF35A4BA79BE Authentication-Results: sourceware.org; arc=none smtp.remote-ip=185.70.43.96 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790865506; cv=none; b=sjv2tPgJvUdDNZEbE1p2naILIcqoumCGTkCJPEY8SkeXsaiMnOUP00OaJTIzTk8efBpwgqM47j0CD4VPRb44Kuqo6VEe5SBlP1mIL1GClOWwoK0Qa42w8l8PVyc6pr3nFmSCRn4nJYpRhBCBaIvQDsUwwYBwm3Qo45BIuZTFQyA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790865506; c=relaxed/simple; bh=ez//BUiBtAUiR0POURswvcqFOLM5Ivd1h6of3PVAuH0=; h=DKIM-Signature:Date:To:From:Subject:Message-ID:MIME-Version; b=peLZzQMQ3HJEtWAFbdz/bqDFZZjSNrVl1mQQitOL+VQu79PeEaiwfloI2/4gFh+R9zoBWoibDJQ1d10vm6oZRh+OzFsplja6Us7QyVt/+9gxIPbJaEcPrv08pbRLSF9UFw2anFAFCCqTxT1VW+HvyEJR8VxjYyZZM9jZVKnefGM= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=vrany.io header.i=@vrany.io header.a=rsa-sha256 header.s=protonmail header.b=AE+ti9na DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF35A4BA79BE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrany.io; s=protonmail; t=1790865498; x=1791124698; bh=C3r5D2dAK3XTqUc6IT0K3mztAMSKEjJrY+V8mhxcY1Y=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=AE+ti9na5zUEtu3QkMZ62D5vsrbADrb73Xs1I9N5tGZBCbCk+7DWjqY0oedbl3U5x rufFNF1ru1Jgn5djBu5c4y4SU6moUYkmDOZGhpv1oNsC0Hmq1jeDwu1p0z9IYggeNv bXpSKcp1cWi9iX+1MbkZEOjllHaEJbmgLZiSJ5Jj57ejmzm+onzLEMV7moniryfLaM wZ6H2+xJRwmfF4jioM6Kj4uni0HIx0J9Fvu4h2KWvHFubMdOOSGmH+yQDY4mghqEjf vo+pBdYLdHkgAXQ3e+nFONL1QHL+mE/zrxSvZiubI0H+nTR6bxPiNkXjnAvSg1OpMj GmIb0ru3eafxQ== Date: Thu, 01 Oct 2026 14:38:13 +0000 To: gdb-patches@sourceware.org From: Jan Vrany Cc: Jan Vrany , Tom Tromey Subject: [pushed] gdb/python: prevent conversion from pointer to bool in to_python() Message-ID: <20261001143803.3871583-1-jan@vrany.io> Feedback-ID: 40767693:user:proton X-Pm-Message-ID: 5c10b41549c538af09e9e9ed4f83fafc70654c7d MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 While converting some Python code to use new "safety" APIs I realized that calling to_python() with a pointer like (for example): to_python (symtab->compunit ().objfile ()) calls to_python(bool) which is unlikely to be what the user wants. This commit changes the code to make it a compile-time error. After trying several approaches, the least intrusive seemed to be handling bool specially in to_python() template for integral types and removing to_python(bool) altogether. This way, the above example fails with: error: no matching function for call to =E2=80=98to_python(objfile*)= =E2=80=99 Tested on x86_64-linux. Approved-By: Tom Tromey --- gdb/python/py-safety.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/gdb/python/py-safety.h b/gdb/python/py-safety.h index 3294f38c8b6..9414951b9ba 100644 --- a/gdb/python/py-safety.h +++ b/gdb/python/py-safety.h @@ -71,17 +71,13 @@ namespace safety_details used in gdb, these are all Python-facing and will return NULL on error. */ =20 -static inline PyObject * -to_python (bool value) -{ - return PyBool_FromLong (value); -} - template>> static inline PyObject * to_python (T value) { - if constexpr (std::is_signed::value) + if constexpr (std::is_same::value) + return PyBool_FromLong (value); + else if constexpr (std::is_signed::value) return gdb_py_object_from_longest (value).release (); else return gdb_py_object_from_ulongest (value).release (); --=20 2.53.0