[PATCH] libstdc++: Allow std::ctype_base masks to contain multiple set bits

Keith Packard keithp@keithp.com
Fri Jan 9 17:18:40 GMT 2026


> From: Jonathan Wakely <jwakely@redhat.com>
> Date: Fri, 09 Jan 2026 11:32:58 +0000
> 
> This will fix at least part of https://gcc.gnu.org/PR51772 (maybe all
> of it, I need to review it properly and refresh my memory of that
> bug).

It fixes the xdigit issue, resolving
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104587 and it removes the
assumption that 'mask' can hold at least 16 bits, so the result should
resolve https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115524

There doesn't seem to be any mention of problems with is(char *, char *,
mask *) though; that causes problems even for cases where a compound
mask value is composed of published mask values, e.g. alnum = alpha |
digit. Compute a mask value for 'a':

        iswalnum('a') -> true
        iswalpha('a') -> true
        iswdigit('a') -> false

        mask = alnum | alpha = digit | alpha

This incorrectly classifies 'a' as a digit.

I've built a test case for this function which covers the C locale
(verifying only ASCII). Would it be reasonable to include that? Should
I expand it to check all of the ctype functions?

-- 
-keith
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20260109/87d99c77/attachment.sig>


More information about the Libstdc++ mailing list