public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/103911] New: std::from_chars shouldn't call isdigit
@ 2022-01-04 23:49 blubban at gmail dot com
  2022-01-05  0:05 ` [Bug libstdc++/103911] " redi at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: blubban at gmail dot com @ 2022-01-04 23:49 UTC (permalink / raw)
  To: gcc-bugs

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?)

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-05-11 15:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-04 23:49 [Bug libstdc++/103911] New: std::from_chars shouldn't call isdigit blubban at gmail dot com
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

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).