From patchwork Tue Apr 9 23:22:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 88266 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 31D883844073 for ; Tue, 9 Apr 2024 23:23:11 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 4043538708B7 for ; Tue, 9 Apr 2024 23:22:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4043538708B7 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4043538708B7 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712704957; cv=none; b=wbVrGNJ19Jq4vwbPkZTBQxpfVE5TqRANXvkNkHwSHvgHd+3FJIm3AwaPxCMUD8QVY3NGyEJN40b6H02cosDWeStcG4Qah/xD1yi0Mlzh0j/LCSFrRYQlEVcd+qWBkUvr6+Ioipmjqs028Zpc4j7wGoAappealQzJOvkSrDGUcSU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712704957; c=relaxed/simple; bh=H7GpdKAmvGX8oC0Qv4bYNQTBfdzMjpdBHW9bTFFrKnA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=KvtTfG0sPL25c+HKxaFtGBF0OsI07HzkTHLLrZfVXE1YbwyTavcgp6jDaDg3nm60pu30UR1gczkUyUooxWGCKJzjl21w3zkevLaavhOWe49DUAmLQFqV6YGq3Q3GlZqRGNrZMjay4oFx442RuLyneJzzIzycntb0NCKwFFtx7vk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712704955; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oqT8hb7GJq+L1zKqnTLqd3PgThMG7tiWizjdjWENDkg=; b=XNCOj+Q9N035HMher3fH0uPmQEBsolSl3E0agNea5bAFLw35234YqrPLxW9/sn6LYybw3T pWWkMU4NTLsSub6EYtXlWL/l3gm6muK2E2UjcMgkWvczeo7nHhn/HHK+RcoEJIw8XbqiOV O+S1KF355kR/kfpt5Tt1+4Z/7wjzeZs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-413-KRYqe_RtPRSqmIGvIFbO5A-1; Tue, 09 Apr 2024 19:22:34 -0400 X-MC-Unique: KRYqe_RtPRSqmIGvIFbO5A-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1131080B557; Tue, 9 Apr 2024 23:22:34 +0000 (UTC) Received: from localhost (unknown [10.42.28.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id D654E444582; Tue, 9 Apr 2024 23:22:33 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix build for targets without FP std::from_chars [PR114633] Date: Wed, 10 Apr 2024 00:22:00 +0100 Message-ID: <20240409232229.252976-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.7 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_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Tested x86_64-linux. Richi confirmed this fixes rx-elf bootstrap. Pushed to trunk. -- >8 -- If the faster std::from_chars is not supported for floating-point types then just extract the value from the stream using operator>>. This fixes a build error for targets where __cpp_lib_to_chars is not defined. libstdc++-v3/ChangeLog: PR libstdc++/114633 * include/bits/chrono_io.h (_Parser::operator()) <'S'>: Use stream extraction if std::from_chars is not available. --- libstdc++-v3/include/bits/chrono_io.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libstdc++-v3/include/bits/chrono_io.h b/libstdc++-v3/include/bits/chrono_io.h index b9eb3d2be53..3b34992b42a 100644 --- a/libstdc++-v3/include/bits/chrono_io.h +++ b/libstdc++-v3/include/bits/chrono_io.h @@ -3685,6 +3685,7 @@ namespace __detail if (!__is_failed(__err)) [[likely]] { long double __val{}; +#if __cpp_lib_to_chars string __str = std::move(__buf).str(); auto __first = __str.data(); auto __last = __first + __str.size(); @@ -3694,6 +3695,9 @@ namespace __detail if ((bool)ec || ptr != __last) [[unlikely]] __err |= ios_base::failbit; else +#else + if (__buf >> __val) +#endif { duration __fs(__val); if constexpr (__is_floating)