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 ESMTP id 00CFE3A7642A for ; Wed, 5 May 2021 21:14:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 00CFE3A7642A Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-140-_3e1TkX1P5mING2qn07fEg-1; Wed, 05 May 2021 17:14:36 -0400 X-MC-Unique: _3e1TkX1P5mING2qn07fEg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B60F64097; Wed, 5 May 2021 21:14:35 +0000 (UTC) Received: from localhost (unknown [10.33.36.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id D00285D9DD; Wed, 5 May 2021 21:14:34 +0000 (UTC) Date: Wed, 5 May 2021 22:14:34 +0100 From: Jonathan Wakely To: =?iso-8859-1?Q?Fran=E7ois?= Dumont Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [committed] libstdc++: Use unsigned char argument to std::isdigit Message-ID: <20210505211434.GV3008@redhat.com> References: <7637b4da-9fcf-c653-ba35-be1e449ec54b@gmail.com> MIME-Version: 1.0 In-Reply-To: <7637b4da-9fcf-c653-ba35-be1e449ec54b@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 May 2021 21:14:39 -0000 On 05/05/21 21:57 +0200, François Dumont via Libstdc++ wrote: >On 05/05/21 2:01 pm, Jonathan Wakely via Libstdc++ wrote: >>Passing plain char to isdigit is undefined if the value is negative. >> >>libstdc++-v3/ChangeLog: >> >> * include/std/charconv (__from_chars_alnum): Pass unsigned >> char to std::isdigit. >> >>Tested powerpc64le-linux. Committed to trunk. >> >       unsigned char __c = *__first; >-      if (std::isdigit(__c)) >+      if (std::isdigit(static_cast(__c))) > >I am very curious to know what this static_cast does on >__c which is already unsigned char ? If it does I'll just start to >hate C++ :-) > >Maybe you wanted to put it on the previous *__first ? Ugh, yes, but it's not even needed there because the implicit conversion is fine. We do need to fix the isspace calls in src/c++11/debug.cc but this one was already correct. Thanks!