From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 904593858C2D; Tue, 26 Apr 2022 13:11:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 904593858C2D MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r10-10560] libstdc++: Do not use std::isdigit in [PR103911] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: 93d720f0ec7651e6a402dda33553817c1ad14ded X-Git-Newrev: b596c35a4ed0143e84422449020296b43a655de7 Message-Id: <20220426131149.904593858C2D@sourceware.org> Date: Tue, 26 Apr 2022 13:11:49 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Apr 2022 13:11:49 -0000 https://gcc.gnu.org/g:b596c35a4ed0143e84422449020296b43a655de7 commit r10-10560-gb596c35a4ed0143e84422449020296b43a655de7 Author: Jonathan Wakely Date: Wed Jan 5 16:25:47 2022 +0000 libstdc++: Do not use std::isdigit in [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) Diff: --- libstdc++-v3/include/std/charconv | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libstdc++-v3/include/std/charconv b/libstdc++-v3/include/std/charconv index daad423570a..12fa39cd13e 100644 --- a/libstdc++-v3/include/std/charconv +++ b/libstdc++-v3/include/std/charconv @@ -39,7 +39,6 @@ #include #include // for __bit_width -#include // for isdigit #include // for __to_chars_len, __to_chars_10_impl #include // for std::errc #include @@ -465,7 +464,7 @@ namespace __detail return true; } - constexpr unsigned char + constexpr char __from_chars_alpha_to_num(char __c) { switch (__c) @@ -549,10 +548,10 @@ namespace __detail case 'Z': return 35; } - return __gnu_cxx::__int_traits::__max; + return 127; } - /// std::from_chars implementation for integers in bases 11 to 26. + /// std::from_chars implementation for integers in bases 11 to 36. template bool __from_chars_alnum(const char*& __first, const char* __last, _Tp& __val, @@ -561,8 +560,8 @@ namespace __detail bool __valid = true; while (__first != __last) { - unsigned char __c = *__first; - if (std::isdigit(__c)) + char __c = *__first; + if ('0' <= __c && __c <= '9') // isdigit __c -= '0'; else {