public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "blubban at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/103911] New: std::from_chars shouldn't call isdigit
Date: Tue, 04 Jan 2022 23:49:46 +0000	[thread overview]
Message-ID: <bug-103911-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103911

            Bug ID: 103911
           Summary: std::from_chars shouldn't call isdigit
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: blubban at gmail dot com
  Target Milestone: ---

In header <charconv>, function __from_chars_alnum calls std::isdigit().

In addition to looking weird ("everyone" knows ctype is locale dependent and
charconv is not), this can cause trouble in a handful of rare cases.

If another thread concurrently calls setlocale, that's a race condition;
additionally, if the locale contains digits other than '0'..'9', from_chars can
return wrong answer. (For example, some versions of Windows libc think 0xB2,
0xB3 and 0xB9 are the digits ²³¹ in the "us" locale.)

GCC will, by default, replace isdigit with c>='0' && c<='9'; to reproduce the
above, use -fno-builtin or Clang.

(Bonus issue: A comment on that function says it applies to bases 11 to 26.
Shouldn't that be 11 to 36?)

             reply	other threads:[~2022-01-04 23:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-04 23:49 blubban at gmail dot com [this message]
2022-01-05  0:05 ` [Bug libstdc++/103911] " redi at gcc dot gnu.org
2022-01-06 14:57 ` cvs-commit at gcc dot gnu.org
2022-01-07 15:19 ` redi at gcc dot gnu.org
2022-04-21 12:33 ` cvs-commit at gcc dot gnu.org
2022-04-26 13:11 ` cvs-commit at gcc dot gnu.org
2022-04-26 13:16 ` redi at gcc dot gnu.org
2022-05-02 11:03 ` cvs-commit at gcc dot gnu.org
2022-05-06 13:13 ` cvs-commit at gcc dot gnu.org
2022-05-11 15:15 ` cvs-commit at gcc dot gnu.org

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=bug-103911-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).