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
* [Bug libstdc++/103911] std::from_chars shouldn't call isdigit
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 ` redi at gcc dot gnu.org
2022-01-06 14:57 ` cvs-commit at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2022-01-05 0:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103911
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2022-01-05
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/103911] std::from_chars shouldn't call isdigit
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
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-06 14:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103911
--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:
https://gcc.gnu.org/g:c83ecfbe74a5cf107642b9c5e1680b548ff1a0e1
commit r12-6281-gc83ecfbe74a5cf107642b9c5e1680b548ff1a0e1
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Jan 5 16:25:47 2022 +0000
libstdc++: Do not use std::isdigit in <charconv> [PR103911]
This avoids a potential race condition if std::setlocale is used
concurrently with std::from_chars.
libstdc++-v3/ChangeLog:
PR libstdc++/103911
* include/std/charconv (__from_chars_alpha_to_num): Return
char instead of unsigned char. Change invalid return value to
127 instead of using numeric trait.
(__from_chars_alnum): Fix comment. Do not use std::isdigit.
Change type of variable to char.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/103911] std::from_chars shouldn't call isdigit
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
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2022-01-07 15:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103911
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Thanks for the report, this is now fixed on trunk. I'll backport it too.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/103911] std::from_chars shouldn't call isdigit
2022-01-04 23:49 [Bug libstdc++/103911] New: std::from_chars shouldn't call isdigit blubban at gmail dot com
` (2 preceding siblings ...)
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
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-21 12:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103911
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:97f9d2f9b2a6172f31c971ac0d99ebc712b2501b
commit r11-9907-g97f9d2f9b2a6172f31c971ac0d99ebc712b2501b
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Jan 5 16:25:47 2022 +0000
libstdc++: Do not use std::isdigit in <charconv> [PR103911]
This avoids a potential race condition if std::setlocale is used
concurrently with std::from_chars.
libstdc++-v3/ChangeLog:
PR libstdc++/103911
* include/std/charconv (__from_chars_alpha_to_num): Return
char instead of unsigned char. Change invalid return value to
127 instead of using numeric trait.
(__from_chars_alnum): Fix comment. Do not use std::isdigit.
Change type of variable to char.
(cherry picked from commit c83ecfbe74a5cf107642b9c5e1680b548ff1a0e1)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/103911] std::from_chars shouldn't call isdigit
2022-01-04 23:49 [Bug libstdc++/103911] New: std::from_chars shouldn't call isdigit blubban at gmail dot com
` (3 preceding siblings ...)
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
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-26 13:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103911
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:b596c35a4ed0143e84422449020296b43a655de7
commit r10-10560-gb596c35a4ed0143e84422449020296b43a655de7
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Jan 5 16:25:47 2022 +0000
libstdc++: Do not use std::isdigit in <charconv> [PR103911]
This avoids a potential race condition if std::setlocale is used
concurrently with std::from_chars.
libstdc++-v3/ChangeLog:
PR libstdc++/103911
* include/std/charconv (__from_chars_alpha_to_num): Return
char instead of unsigned char. Change invalid return value to
127 instead of using numeric trait.
(__from_chars_alnum): Fix comment. Do not use std::isdigit.
Change type of variable to char.
(cherry picked from commit c83ecfbe74a5cf107642b9c5e1680b548ff1a0e1)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/103911] std::from_chars shouldn't call isdigit
2022-01-04 23:49 [Bug libstdc++/103911] New: std::from_chars shouldn't call isdigit blubban at gmail dot com
` (4 preceding siblings ...)
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
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2022-04-26 13:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103911
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |10.4
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for 10.4 and 11.4, but I'm not going to bother for 9.5, so I'll close
this now. Thanks again for the report.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/103911] std::from_chars shouldn't call isdigit
2022-01-04 23:49 [Bug libstdc++/103911] New: std::from_chars shouldn't call isdigit blubban at gmail dot com
` (5 preceding siblings ...)
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
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-02 11:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103911
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:86d821ddf5615e693ead667b2580898f46de8eb9
commit r13-70-g86d821ddf5615e693ead667b2580898f46de8eb9
Author: Patrick Palka <ppalka@redhat.com>
Date: Mon May 2 07:01:33 2022 -0400
libstdc++: Don't use std::tolower in <charconv> [PR103911]
As with std::isdigit in r12-6281-gc83ecfbe74a5cf, we shouldn't be using
std::tolower in <charconv> either.
PR libstdc++/103911
libstdc++-v3/ChangeLog:
* src/c++17/floating_from_chars.cc (find_end_of_float): Accept
two delimeters for the exponent part in the form of a possibly
NULL string of length two. Don't use std::tolower.
(pattern): Adjust calls to find_end_of_float accordingly.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/103911] std::from_chars shouldn't call isdigit
2022-01-04 23:49 [Bug libstdc++/103911] New: std::from_chars shouldn't call isdigit blubban at gmail dot com
` (6 preceding siblings ...)
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
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-06 13:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103911
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:eed2cd48cd5e8d94ceb15c5fd86cdd27926b54b5
commit r12-8349-geed2cd48cd5e8d94ceb15c5fd86cdd27926b54b5
Author: Patrick Palka <ppalka@redhat.com>
Date: Mon May 2 07:01:33 2022 -0400
libstdc++: Don't use std::tolower in <charconv> [PR103911]
As with std::isdigit in r12-6281-gc83ecfbe74a5cf, we shouldn't be using
std::tolower in <charconv> either.
PR libstdc++/103911
libstdc++-v3/ChangeLog:
* src/c++17/floating_from_chars.cc (find_end_of_float): Accept
two delimeters for the exponent part in the form of a possibly
NULL string of length two. Don't use std::tolower.
(pattern): Adjust calls to find_end_of_float accordingly.
(cherry picked from commit 86d821ddf5615e693ead667b2580898f46de8eb9)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/103911] std::from_chars shouldn't call isdigit
2022-01-04 23:49 [Bug libstdc++/103911] New: std::from_chars shouldn't call isdigit blubban at gmail dot com
` (7 preceding siblings ...)
2022-05-06 13:13 ` cvs-commit at gcc dot gnu.org
@ 2022-05-11 15:15 ` cvs-commit at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-11 15:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103911
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:39099827b0f731b5f2da696f6f580156c8a7819c
commit r11-9979-g39099827b0f731b5f2da696f6f580156c8a7819c
Author: Patrick Palka <ppalka@redhat.com>
Date: Mon May 2 07:01:33 2022 -0400
libstdc++: Don't use std::tolower in <charconv> [PR103911]
As with std::isdigit in r12-6281-gc83ecfbe74a5cf, we shouldn't be using
std::tolower in <charconv> either.
PR libstdc++/103911
libstdc++-v3/ChangeLog:
* src/c++17/floating_from_chars.cc (find_end_of_float): Accept
two delimeters for the exponent part in the form of a possibly
NULL string of length two. Don't use std::tolower.
(pattern): Adjust calls to find_end_of_float accordingly.
(cherry picked from commit 86d821ddf5615e693ead667b2580898f46de8eb9)
^ 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).