Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Jan Vrany <jan@vrany.io>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/python: prevent conversion from pointer to bool in to_python()
Date: Wed, 30 Sep 2026 08:18:13 -0600	[thread overview]
Message-ID: <87wls2hlga.fsf@tromey.com> (raw)
In-Reply-To: <20260930093550.1288712-1-jan@vrany.io> (Jan Vrany's message of "Wed, 30 Sep 2026 09:36:09 +0000")

>>>>> "Jan" == Jan Vrany <jan@vrany.io> writes:

Jan> While converting some Python code to use new "safety" APIs I realized
Jan> that calling to_python() with a pointer like (for example):

Jan>    to_python (symtab->compunit ().objfile ())

Jan> calls to_python(bool) which is unlikely to be what the user wants.
Jan> This commit changes the code to make it a compile-time error.

Jan> After trying several approaches, the least intrusive seemed to be
Jan> handling bool specially in to_python() template for integral types and
Jan> removing to_python(bool) altogether. This way, the above example fails
Jan> with:

Jan>     error: no matching function for call to ‘to_python(objfile*)’

Reading this made me wonder if we'd prefer a template function that
accepts pointer types but then causes a compile error.

But I think this approach is fine too.

Approved-By: Tom Tromey <tom@tromey.com>

Tom

      reply	other threads:[~2026-09-30 14:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30  9:36 Jan Vrany
2026-09-30 14:18 ` Tom Tromey [this message]

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=87wls2hlga.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan@vrany.io \
    /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: link
Be 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