From patchwork Tue Dec 20 08:47:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 34994 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2849146wrn; Tue, 20 Dec 2022 00:48:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXuKjGlbAATTpIxH9QQF5vvuvM50dTzxf4GcJE/a3+QvoJ1mx2jNk6+hP1UzJlOkbZ3QebvI X-Received: by 2002:a05:6402:3226:b0:472:1f66:abb with SMTP id g38-20020a056402322600b004721f660abbmr24101119eda.40.1671526107130; Tue, 20 Dec 2022 00:48:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671526107; cv=none; d=google.com; s=arc-20160816; b=fkRSxZJtFbvUzwMfWncWZQO28fOqPH6mJZOGRwBDerXTXG7ueKM3E1ItrR9YSKcLB/ MOz17Gr5wqE5qck/XDMwi9w+N+FyLR0rfbOzNEyoYEe0wvOomq6M+m9DmKTsjbQIe6j1 qH1oHQV+fCYHzPCLtz0AZEg1wrSWYOzm1Fuxkbip9SHTK0bjlyZRRY+icqkDdEWNhTH/ RDCR5ngGKmqEQizre9n+zd9Swbta19eOTHd/WsUGKrjHTZBJnvcwz339u2SmkAC7s0zS lO3rKRIOgAVbRCx/p9YYgcN1648j9yRGIUtNGvCoxpuUA6w2WMZQ/h3MWssIdpwBDr3r NlcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=BxhVRhliGyAPDI3VDnILf3WmkF+GkAgNYrK2uStrgMs=; b=eWtnLaWOmhru2j8L0OteP9i06aXFTqShax8siHQqbXfk+QAuooJLrPMx2eB5mPNn96 TZ7RwoabN/fKGRduRbhWsTfpBvRQRZoK1s6LR/IK08CQAvs5vtIcHVRYf/bWakcxaP2f +XZLZl3rr7wVYH9D9BsD8MvpFqYakcGLQUn7tTDLzC2q2JjP1LD5jkkMfDmEfXncrfxq yYc9e65PPXbKo0+5NQrpGxV++2sxaxwIcMW+ExHOEWPC9xgukf5pFrspUMBh3xYSp7Vh RAZq3BdElR4F11QHT2bv6rOURgO3hWW+2qJdSm71kdlMH3BbEYPe5aDf6MwNirri92Xe 5EKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=HjrmgGzP; 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=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id w16-20020aa7da50000000b0047becc52217si1777101eds.292.2022.12.20.00.48.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 00:48:27 -0800 (PST) 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=@gcc.gnu.org header.s=default header.b=HjrmgGzP; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 20F8D3858C2C for ; Tue, 20 Dec 2022 08:48:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 20F8D3858C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671526106; bh=BxhVRhliGyAPDI3VDnILf3WmkF+GkAgNYrK2uStrgMs=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=HjrmgGzPtaqZXMWJdWnHcfk09CwtyxJf5DbW9cUw0T9xSwsxOSSa0iwvLkRH7JPTe PLB/z4pL4z+DVwoeWHT7sNOhxtp6gmj+APULg5kk/9cI9TsYs7anujE6NhdZ1w2YNv drTTgkBCebCsQgJeTBJyCaKovs43D2vdMSmqlBWw= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 5ECC03858D3C for ; Tue, 20 Dec 2022 08:47:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5ECC03858D3C 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-294-TNfYH-84NqyzXTg1-G5KbA-1; Tue, 20 Dec 2022 03:47:39 -0500 X-MC-Unique: TNfYH-84NqyzXTg1-G5KbA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 92241101A52E; Tue, 20 Dec 2022 08:47:39 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.195.114]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4BE652166B26; Tue, 20 Dec 2022 08:47:39 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 2BK8lam8803080 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 20 Dec 2022 09:47:36 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 2BK8lUxv803079; Tue, 20 Dec 2022 09:47:30 +0100 Date: Tue, 20 Dec 2022 09:47:29 +0100 To: Jonathan Wakely Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: [PATCH] libstdc++: Don't call 4-5 argument to_chars with chars_format{} Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752722159264033447?= X-GMAIL-MSGID: =?utf-8?q?1752722159264033447?= Hi! In Fedora build libstdc++.so is built with assertions enabled and FAIL: 20_util/to_chars/float128_c++23.cc execution test was failing on all arches. The problem is that it called 5 argument version of to_chars with chars_format{}, which C++ says is invalid: http://eel.is/c++draft/charconv.to.chars#12 Preconditions: fmt has the value of one of the enumerators of chars_format. The following patch fixes it by skipping the second part of the test which needs the 5 argument to_chars for chars_format{}, but because it is strictly speaking invalid also for 4 argument to_chars, it uses 3 argument to_chars instead of 4 argument to_chars with last argument chars_format{}. Bootstrapped/regtested on {x86_64,i686,aarch64,powerpc64le,s390x}-linux, ok for trunk? 2022-12-20 Jakub Jelinek * testsuite/20_util/to_chars/float16_c++23.cc (test): Use 3 argument std::to_chars if fmt is std::chars_format{}, rather than 4 argument. * testsuite/20_util/to_chars/float128_c++23.cc (test): Likewise, and skip second part of testing that requires 5 argument std::to_chars. Jakub --- libstdc++-v3/testsuite/20_util/to_chars/float16_c++23.cc.jj 2022-11-01 22:45:50.653626818 +0100 +++ libstdc++-v3/testsuite/20_util/to_chars/float16_c++23.cc 2022-12-19 16:23:28.989733811 +0100 @@ -36,9 +36,16 @@ test(std::chars_format fmt = std::chars_ for (int i = 0; i <= (unsigned short) ~0; ++i) { u.s = i; - auto [ptr1, ec1] = std::to_chars(str1, str1 + sizeof(str1), u.f, fmt); - auto [ptr2, ec2] = std::to_chars(str2, str2 + sizeof(str2), std::float32_t(u.f), fmt); - VERIFY( ec1 == std::errc() && ec2 == std::errc()); + auto [ptr1, ec1] = (fmt == std::chars_format{} + ? std::to_chars(str1, str1 + sizeof(str1), u.f) + : std::to_chars(str1, str1 + sizeof(str1), u.f, + fmt)); + auto [ptr2, ec2] = (fmt == std::chars_format{} + ? std::to_chars(str2, str2 + sizeof(str2), + std::float32_t(u.f)) + : std::to_chars(str2, str2 + sizeof(str2), + std::float32_t(u.f), fmt)); + VERIFY( ec1 == std::errc() && ec2 == std::errc() ); // std::cout << i << ' ' << std::string_view (str1, ptr1) // << '\t' << std::string_view (str2, ptr2) << '\n'; if (fmt == std::chars_format::fixed) --- libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc.jj 2022-11-25 22:23:44.540104246 +0100 +++ libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc 2022-12-19 16:24:49.142571475 +0100 @@ -60,7 +60,9 @@ test(std::chars_format fmt = std::chars_ char str1[10000], str2[10000]; for (auto u : tests) { - auto [ptr1, ec1] = std::to_chars(str1, str1 + sizeof(str1), u, fmt); + auto [ptr1, ec1] = (fmt == std::chars_format{} + ? std::to_chars(str1, str1 + sizeof(str1), u) + : std::to_chars(str1, str1 + sizeof(str1), u, fmt)); VERIFY( ec1 == std::errc() ); // std::cout << u << ' ' << std::string_view (str1, ptr1) << '\n'; if (fmt == std::chars_format::fixed) @@ -77,13 +79,14 @@ test(std::chars_format fmt = std::chars_ VERIFY( ec4 == std::errc() && ptr4 == ptr1 ); VERIFY( u == v ); + if (fmt == std::chars_format{}) + continue; + auto [ptr5, ec5] = std::to_chars(str1, str1 + sizeof(str1), u, fmt, 90); VERIFY( ec5 == std::errc() ); // std::cout << u << ' ' << std::string_view (str1, ptr5) << '\n'; v = 4.0f128; - auto [ptr6, ec6] = std::from_chars(str1, ptr5, v, - fmt == std::chars_format{} - ? std::chars_format::general : fmt); + auto [ptr6, ec6] = std::from_chars(str1, ptr5, v, fmt); VERIFY( ec6 == std::errc() && ptr6 == ptr5 ); if (fmt == std::chars_format::fixed && u > 0.0f128 && u < 0.000001f128) VERIFY( v == 0.0 );