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 via email to