From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 9CB29385800B for ; Thu, 6 Jan 2022 14:57:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9CB29385800B Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-564-peflvyizOOWX5CEOEVdF_g-1; Thu, 06 Jan 2022 09:57:28 -0500 X-MC-Unique: peflvyizOOWX5CEOEVdF_g-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1A6D51B2C980; Thu, 6 Jan 2022 14:57:27 +0000 (UTC) Received: from localhost (unknown [10.33.36.252]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC0927EBF8; Thu, 6 Jan 2022 14:57:26 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Do not use std::isdigit in [PR103911] Date: Thu, 6 Jan 2022 14:57:25 +0000 Message-Id: <20220106145725.1932037-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jan 2022 14:57:31 -0000 Tested powerpc64le-linux, pushed to trunk. 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. --- 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 4337a9e52f9..a3f8c7718b2 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 @@ -466,7 +465,7 @@ namespace __detail return true; } - constexpr unsigned char + constexpr char __from_chars_alpha_to_num(char __c) { switch (__c) @@ -550,10 +549,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, @@ -562,8 +561,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 { -- 2.31.1