From patchwork Fri Oct 20 16:34:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 156246 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp1221297vqb; Fri, 20 Oct 2023 10:38:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFzNaNlzJQQ7k98XZDmq5/q8fu8irBH4OQPaQwEcQaSWGvvycGMgL9aPNb8/giggLcyR65b X-Received: by 2002:a05:620a:29d4:b0:778:9235:3d0f with SMTP id s20-20020a05620a29d400b0077892353d0fmr2787438qkp.29.1697823511222; Fri, 20 Oct 2023 10:38:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697823511; cv=pass; d=google.com; s=arc-20160816; b=qxVns0IXKie6CU630P8ynFJsJH4RUBfES+AnHviQMRybnYlbjsWvHDROX5EBTRp8DI o+gtv3CSyqyIiWOzyZ4CnWS0C49d8305Lo0ZOMhzQZC/cBWk8mZEwpir5D29QEo3Tlfq 5F8fkxMinDpq/NlX/HjD4+pCyh8DKyJMULX8KGVq5u2kt1sQhmWsy3ermuvNsvRCPg7p tesJN4MJ1wSjmCJ4P95DS9vTvs2GTDhNrkOIRvFfrEuh47BIJiWHBazuRMjZ6wGIDg+P YBNTg64f5bH9o5UpVa8ouUrojuoMMsKTfvTzXAgQSG3wkrgUazoKd8t9Mo57/upwnLvI siZA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=cbkcGEE0bwv9ILTWiashLbg+H57nr+EYzF6SL3ripoE=; fh=GDwminWOgAKRAcggvkBeIqUDJ9a4jDqk/BfstkiuMK0=; b=PU7JJeibzdClLCPteHrqnEVdu6aMgfNKEVA/+2DHAjJXz955F0WoAD8FMIAVJuBU4U VoYB1loGjgOYimfyyMeMFn983PlXUtK1Yl+n6MHhtuce25901wq/Q1NCCagl9wLO4TIt UriZvBBxshICuip1W9/pvmKKz+ogvR9N37njkHG7TvdICR1WkL9J6F2+isxpYokrmQL3 +sAgYqDglxHr2F63jCVGn0tl4+mMkBpNlet0wHKm/OfS/St5Lr+JgfEHcukgv6mVfizS mlVt9CcM7JGXlsnQfMWqVDUyY22W/hyfD311v/mhVAFA7qkCwkmjv+B6zuGhY1dSGqJb 01aA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="NdovqK/4"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id r17-20020a05620a299100b00773e6deb673si1803928qkp.670.2023.10.20.10.38.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 10:38:31 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="NdovqK/4"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9543B3856DF1 for ; Fri, 20 Oct 2023 16:35:15 +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 146C93858D20 for ; Fri, 20 Oct 2023 16:34:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 146C93858D20 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 146C93858D20 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=1697819689; cv=none; b=QELp49WpEgKeVhbSKeAckAczP2X3XyMGFfXOwWKL8RlA5ey/eCOFOGjdu07f3X/npgZgpRm+ojHlqk9QXVNGv4IZOj2tIl6PUbeV2D/oLzkhajoQcnzzF1UzUHNv/KqYk5GyxojdHqT9WHde2oux19v/oG6CDiymQ9FtxAoIEa4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697819689; c=relaxed/simple; bh=iSz7PU8nn8qkA4pdsFpzHwaOTQl1kjhK5Xp20pqZArA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=H4MYSJoi1TMLu1l4xuuUFMAGpXTXtfuL3tjdnStTyYFMAiquVOKL+efNHLzihboqR1J4L+2448KwdsMBqOvEMj1JtSIkacr7R5Ekb0gkZwuB9ggXSuKHGF0MPtsmy7y/w3xh+NRu8cm+73+XoUA9rJ/+wx/9P/1D/hS3z9ftxR4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697819687; 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=cbkcGEE0bwv9ILTWiashLbg+H57nr+EYzF6SL3ripoE=; b=NdovqK/4xbIamZbNmquy84B7YWay6Hvmv24NgG1nLbUroyxdzrcMc4rAxBLipgQ/MesO1G zBgxpoNuaFnyiITW1itD+ZkYZjHbIBeS0U0Apys7aO7rVX058cyFunfHFY0g8VVuGGW7v7 DlqP3rjElqX3Zi8whV2v63sfD6oBSJ0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-607-lJHoNMSkPB2baAn7xvS1oQ-1; Fri, 20 Oct 2023 12:34:31 -0400 X-MC-Unique: lJHoNMSkPB2baAn7xvS1oQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 16F1A87A9F5; Fri, 20 Oct 2023 16:34:31 +0000 (UTC) Received: from pdp-11.lan (unknown [10.22.17.177]) by smtp.corp.redhat.com (Postfix) with ESMTP id E902140C6F7B; Fri, 20 Oct 2023 16:34:30 +0000 (UTC) From: Marek Polacek To: GCC Patches , libstdc++ Subject: [pushed] libstdc++: add casts to from_chars in [PR111883] Date: Fri, 20 Oct 2023 12:34:13 -0400 Message-ID: <20231020163413.25404-1-polacek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.0 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780296986398305146 X-GMAIL-MSGID: 1780296986398305146 Tested x86_64-pc-linux-gnu, applying to trunk. -- >8 -- This fixes .../charconv: In function 'std::from_chars_result std::from_chars(const char*, const char*, _Float16&, chars_format)': .../charconv:687:17: warning: converting to '_Float16' from 'float' with greater conversion rank 687 | __value = __val; | ^~~~~ .../charconv: In function 'std::from_chars_result std::from_chars(const char*, const char*, __gnu_cxx::__bfloat16_t&, chars_format)': .../charconv:763:17: warning: converting to '__gnu_cxx::__bfloat16_t' {aka '__bf16'} from 'float' with greater conversion rank 763 | __value = __val; | ^~~~~ which was breaking a test: FAIL: g++.dg/warn/Wstringop-overflow-6.C -std=gnu++26 (test for excess errors) libstdc++-v3/ChangeLog: * include/std/charconv (from_chars): Add explicit casts. --- libstdc++-v3/include/std/charconv | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) base-commit: eb15fad3190a8b33e3e451b964ff1ecf08bbb113 diff --git a/libstdc++-v3/include/std/charconv b/libstdc++-v3/include/std/charconv index cb428fe6d3b..6cb7fecff87 100644 --- a/libstdc++-v3/include/std/charconv +++ b/libstdc++-v3/include/std/charconv @@ -684,7 +684,7 @@ namespace __detail from_chars_result __res = __from_chars_float16_t(__first, __last, __val, __fmt); if (__res.ec == errc{}) - __value = __val; + __value = _Float16(__val); return __res; } #endif @@ -697,7 +697,7 @@ namespace __detail float __val; from_chars_result __res = from_chars(__first, __last, __val, __fmt); if (__res.ec == errc{}) - __value = __val; + __value = _Float32(__val); return __res; } #endif @@ -710,7 +710,7 @@ namespace __detail double __val; from_chars_result __res = from_chars(__first, __last, __val, __fmt); if (__res.ec == errc{}) - __value = __val; + __value = _Float64(__val); return __res; } #endif @@ -723,7 +723,7 @@ namespace __detail long double __val; from_chars_result __res = from_chars(__first, __last, __val, __fmt); if (__res.ec == errc{}) - __value = __val; + __value = _Float128(__val); return __res; } #elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH) @@ -739,7 +739,7 @@ namespace __detail __extension__ __ieee128 __val; from_chars_result __res = from_chars(__first, __last, __val, __fmt); if (__res.ec == errc{}) - __value = __val; + __value = _Float128(__val); return __res; } #else @@ -760,7 +760,7 @@ namespace __detail from_chars_result __res = __from_chars_bfloat16_t(__first, __last, __val, __fmt); if (__res.ec == errc{}) - __value = __val; + __value = __gnu_cxx::__bfloat16_t(__val); return __res; } #endif