From patchwork Thu Sep 15 17:44:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Letu Ren X-Patchwork-Id: 57670 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 38B19389838B for ; Thu, 15 Sep 2022 17:45:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 38B19389838B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663263935; bh=kLriDeY9FeoesrtexCzf+1ShgHJ6Yk1gDpJhWLpHKeY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=A0aMOyOErih0Vr0FlDjIcUOsaE55qgIoCWvb0VpJ9LqbAq9EcpQInsRzxljZnop4k 8yp0haV52WFWBjDO3k6SmNbSGDlHgsTeKCoFrZ7ZqpD4dzYJKENeyBoVYavXLlcOJd PPurC+kFJn6bM61SwdK7YPLnA+2N8raWg4ub0EB0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id EB4193857BA2 for ; Thu, 15 Sep 2022 17:45:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EB4193857BA2 Received: by mail-pf1-x433.google.com with SMTP id y136so18798493pfb.3 for ; Thu, 15 Sep 2022 10:45:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=kLriDeY9FeoesrtexCzf+1ShgHJ6Yk1gDpJhWLpHKeY=; b=KwhtZZhWaOura1dw5uSSFcSkoBUF4eTp4DYw+KvtoEqnWP7EF+rfpoPZw66OeRMfvz bn4hnpzCTFcEICSfq3W5TvIj5PMJhAibS+U4AQ5beGzSkFVv5g9RymXr7wRlNy29MIyU nVnxfkqFGriG1mGPOys1I+TfRzWasTBwC5GzPbEO/nA3gT52qru5ETxMDhPyg64lm7kz r8CLnw/37PXdwfu+uKAA5p7CT03aDXW8Vw66XmZY5A2SgcdQKPc5aqUl/yVevh2V15Ar IYVYAzbxk/f2zWbiO115/Y0HvgG/pyH5x2K47fybma3ciWdJx7gYKbo9dDkIWx2227T7 SR+g== X-Gm-Message-State: ACrzQf0DjldVcZKOL+RY2Vgdp4l9A68km7nSWuFGU1Co/J75wV8IDJnA H5HDryZS25x4yqTbwmxLn2eiGcfyHUlzdg== X-Google-Smtp-Source: AMsMyM5FxL2I5JL2RqSZbODghsaaPV/9Tm+8XY95ZUBm1XVBGYYIPBJaH3o8+q+DUiGrdSn2tbuXPg== X-Received: by 2002:a05:6a00:170c:b0:537:27b4:ebfe with SMTP id h12-20020a056a00170c00b0053727b4ebfemr581455pfc.19.1663263909690; Thu, 15 Sep 2022 10:45:09 -0700 (PDT) Received: from fanta-arch.localdomain ([2406:da1e:8db:a800:58a3:2979:14fa:1426]) by smtp.gmail.com with ESMTPSA id mn22-20020a17090b189600b00200a85fa777sm2011838pjb.1.2022.09.15.10.45.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 10:45:09 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH] stdlib/strfrom: Remove the -NAN testcase (bug 29501) Date: Fri, 16 Sep 2022 01:44:21 +0800 Message-Id: <20220915174421.4414-1-fantasquex@gmail.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Letu Ren via Libc-alpha From: Letu Ren Reply-To: Letu Ren Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" From: FantasqueX According to the specification of ISO/IEC TS 18661-1:2014, The strfromd, strfromf, and strfroml functions are equivalent to snprintf(s, n, format, fp) (7.21.6.5), except the format string contains only the character %, an optional precision that does not contain an asterisk *, and one of the conversion specifiers a, A, e, E, f, F, g, or G, which applies to the type (double, float, or long double) indicated by the function suffix (rather than by a length modifier). Use of these functions with any other 20 format string results in undefined behavior. strfromf will convert the arguement with type float to double first. According to the latest version of IEEE754 which is published in 2019, Conversion of a quiet NaN from a narrower format to a wider format in the same radix, and then back to the same narrower format, should not change the quiet NaN payload in any way except to make it canonical. When either an input or result is a NaN, this standard does not interpret the sign of a NaN. However, operations on bit strings—copy, negate, abs, copySign—specify the sign bit of a NaN result, sometimes based upon the sign bit of a NaN operand. The logical predicates totalOrder and isSignMinus are also affected by the sign bit of a NaN operand. For all other operations, this standard does not specify the sign bit of a NaN result, even when there is only one input NaN, or when the NaN is produced from an invalid operation. converting NAN or -NAN with type float to double doesn't need to keep the signbit. As a result, this test case isn't mandatory. The problem is that according to RISC-V ISA manual in chapter 11.3 of riscv-isa-20191213, Except when otherwise stated, if the result of a floating-point operation is NaN, it is the canonical NaN. The canonical NaN has a positive sign and all significand bits clear except the MSB, a.k.a. the quiet bit. For single-precision floating-point, this corresponds to the pattern 0x7fc00000. which means that conversion -NAN from float to double won't keep the signbit. As this test case isn't mandatory and may fail on some architecture, it is OK to remove it. Signed-off-by: Letu Ren --- stdlib/tst-strfrom.c | 1 - 1 file changed, 1 deletion(-) diff --git a/stdlib/tst-strfrom.c b/stdlib/tst-strfrom.c index 3a447eac12..1533fb9170 100644 --- a/stdlib/tst-strfrom.c +++ b/stdlib/tst-strfrom.c @@ -37,7 +37,6 @@ static const struct test tests[] = { TEST ("5.900000e-16", "%e", 50, 12, 5.9e-16), TEST ("1.234500e+20", "%e", 50, 12, 12.345e19), TEST ("1.000000e+05", "%e", 50, 12, 1e5), - TEST ("-NAN", "%G", 50, 4, -NAN_), TEST ("-inf", "%g", 50, 4, -INF), TEST ("inf", "%g", 50, 3, INF) };