Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tromey@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 0/3] Use gnulib c-ctype module, not <ctype.h>
Date: Wed, 20 Aug 2025 13:14:33 -0400	[thread overview]
Message-ID: <c32d74a3-1cbd-4825-beb6-aa667716d556@simark.ca> (raw)
In-Reply-To: <87h5yiq32b.fsf@tromey.com>

On 8/7/25 4:39 PM, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
> 
> Simon> My understanding is that poisoning using macros doesn't work, because it
> Simon> interferes with identifiers of the same name in other headers.  But
> Simon> would it be possible to do it using "#pragma GCC poison"?  Like:
> 
> I didn't try it but that's because I believe it won't work.
> 
> The pragma is better than the preprocessor approach, the manual says:
> 
>      If a poisoned identifier appears as part of the expansion of a
>      macro which was defined before the identifier was poisoned, it will
>      _not_ cause an error.  This lets you poison an identifier without
>      worrying about system headers defining macros that use it.
> 
> However in our case the poisoning would likely occur before the
> inclusion of the offending header.  The workaround would be to include
> the locale (and maybe iostream?) headers everywhere, but I think we
> definitely should not do that.
> 
> FTR the failure I saw (with cpp-style poisoning, a la safe-ctype.h) came
> from source-cache.c which includes some locale stuff via <sstream>.

Indeed, it doesn't work:

  CXX      agent.o
In file included from ../gnulib/import/ctype.h:35,
                 from /usr/include/c++/15.2.1/cctype:47,
                 from /usr/include/c++/15.2.1/bits/localefwd.h:44,
                 from /usr/include/c++/15.2.1/string:47,
                 from /home/smarchi/src/binutils-gdb/gdbsupport/ptid.h:36,
                 from /home/smarchi/src/binutils-gdb/gdbsupport/common-defs.h:214,
                 from <command-line>:
/usr/include/ctype.h:108:12: error: attempt to use poisoned ‘isalnum’
  108 | __exctype (isalnum);
      |            ^
/home/smarchi/src/binutils-gdb/gdbsupport/common-defs.h:208:20: note: poisoned here
  208 | #pragma GCC poison isalnum
      |                    ^~~~~~~

> The main issue here is that the pragma works on an identifier basis but
> really we'd like to be more selective and only exclude some particular
> functions.

As far as I'm concerned, this patch series LGTM, I'm not aware of better
alternatives.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon

  reply	other threads:[~2025-08-20 17:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-06 13:13 Tom Tromey
2025-08-06 13:13 ` [PATCH 1/3] Import the c-ctype module from gnulib Tom Tromey
2025-08-06 13:13 ` [PATCH 2/3] Use c-ctype.h (not safe-ctype.h) in gdb Tom Tromey
2025-08-06 13:13 ` [PATCH 3/3] Use gnulib c-ctype module " Tom Tromey
2025-08-06 19:46 ` [PATCH 0/3] Use gnulib c-ctype module, not <ctype.h> Simon Marchi
2025-08-07 20:39   ` Tom Tromey
2025-08-20 17:14     ` Simon Marchi [this message]
2025-09-09 17:53       ` Tom Tromey
2025-09-09 18:01         ` Simon Marchi
2025-09-09 18:55           ` Tom Tromey
2025-10-14 13:00 ` Guinevere Larsen
2025-10-14 19:19   ` Tom Tromey
2025-10-16 15:30     ` Tom Tromey
2025-10-16 21:50       ` Luis
2025-10-21 12:59         ` Tom Tromey
2025-10-21 17:37         ` Simon Marchi

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=c32d74a3-1cbd-4825-beb6-aa667716d556@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@adacore.com \
    /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