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 [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id C1AB8385803B for ; Thu, 7 Jan 2021 15:38:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C1AB8385803B Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-34-9frcdut5OGiXqUCTU13QGg-1; Thu, 07 Jan 2021 10:38:03 -0500 X-MC-Unique: 9frcdut5OGiXqUCTU13QGg-1 Received: by mail-qk1-f199.google.com with SMTP id g4so6375118qko.23 for ; Thu, 07 Jan 2021 07:38:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1h5BozzjBXG0ADpXBvKmPrd66RGeytFTyEWzQ16rzxk=; b=IVMgWZF8DJT0lACW27MN/8NE1Vz8FKNLglKxDnve7Nu9U3eFGTyjDY3fHexUcpX14C Y3/7mgZBAS7wEU3P7tl8I4xOLCPUQfl7A4T28SLUoMzK8GxD//EQaDWzZ/Fk9qRxUotC IoZveJ8GSQn4myvv9rXzOfRGmvBKh5zgFBQj5vXVWraOpgSzUmRLCq+tz0XTMO6Yel6Z i0BVk7Um33ln80aFjNU9oaxIcEO/RhB/Br83Ba8p/Zy9qwzyn7B2K6/br9vgy8XF9Acd 8hcUrNU57mhhEXSjEUvxjgdceqYbJlJc6adT2oP0TTAszeXBNKD8QxGGnAn3RHdSFPk9 sl1A== X-Gm-Message-State: AOAM5321iGGquLz612zpAPpxcZ4VGOVMJbuLfenVoHTyXzCTCn6GSk90 c53TKmx64RngfB0ieal1eX9r/ZWlq20koF68l8FZdDlutVVNydd1sty6YH9GI5nAUsrEHrz1wvK sgFKrasDdumDJ+SGnJXEIJ2htvveE8VR7j5oDxpUwSbNbsyZS845QS02YJwGGdQuXniw= X-Received: by 2002:ac8:5a90:: with SMTP id c16mr8898677qtc.331.1610033882776; Thu, 07 Jan 2021 07:38:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzIJIaZwrEVBrXMs3zu9/k/vwMNtmWh3VvuZEb++ypzlfTIGouqoHZ24r5A3Imjx1l0wJYn/Q== X-Received: by 2002:ac8:5a90:: with SMTP id c16mr8898652qtc.331.1610033882532; Thu, 07 Jan 2021 07:38:02 -0800 (PST) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id h26sm2756768qtq.18.2021.01.07.07.38.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 07:38:01 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Patrick Palka Subject: [PATCH] libstdc++: Fix long double to_chars testcase [PR98384] Date: Thu, 7 Jan 2021 10:37:59 -0500 Message-Id: <20210107153759.1939075-1-ppalka@redhat.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-16.4 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_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: Thu, 07 Jan 2021 15:38:07 -0000 The testcase was failing to compile on some targets due to its use of the non-standard functions nextupl and nextdownl. This patch makes the testcase instead use the C99 function nexttowardl in an equivalent manner. libstdc++-v3/ChangeLog: PR libstdc++/98384 * testsuite/20_util/to_chars/long_double.cc: Use nexttowardl instead of the non-standard nextupl and nextdownl. --- .../testsuite/20_util/to_chars/long_double.cc | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/libstdc++-v3/testsuite/20_util/to_chars/long_double.cc b/libstdc++-v3/testsuite/20_util/to_chars/long_double.cc index 9d9ede7cf8a..4f72cb65400 100644 --- a/libstdc++-v3/testsuite/20_util/to_chars/long_double.cc +++ b/libstdc++-v3/testsuite/20_util/to_chars/long_double.cc @@ -32,6 +32,17 @@ using namespace std; +namespace detail +{ + long double + nextupl(long double x) + { return nexttowardl(x, numeric_limits::infinity()); } + + long double + nextdownl(long double x) + { return nexttowardl(x, -numeric_limits::infinity()); } +} + // The long double overloads of std::to_chars currently just go through printf // (except for the hexadecimal formatting). @@ -40,8 +51,8 @@ void test01() { const long double hex_testcases[] - = { nextdownl(numeric_limits::max()), - nextupl(numeric_limits::min()), + = { detail::nextdownl(numeric_limits::max()), + detail::nextupl(numeric_limits::min()), 42.0L, 0x1.2p+0L, 0x1.23p+0L, @@ -94,7 +105,7 @@ test01() { // Verify that the nearby values have a different shortest form. - testcase = nextdownl(testcase); + testcase = detail::nextdownl(testcase); result = to_chars(begin(to_chars_buffer), end(to_chars_buffer), testcase, chars_format::hex); VERIFY( result.ec == errc{} ); @@ -103,7 +114,7 @@ test01() sprintf(printf_buffer, "%La", testcase); VERIFY( !strcmp(to_chars_buffer, printf_buffer+strlen("0x")) ); - testcase = nextupl(nextupl(testcase)); + testcase = detail::nextupl(detail::nextupl(testcase)); result = to_chars(begin(to_chars_buffer), end(to_chars_buffer), testcase, chars_format::hex); VERIFY( result.ec == errc{} ); @@ -112,7 +123,7 @@ test01() sprintf(printf_buffer, "%La", testcase); VERIFY( !strcmp(to_chars_buffer, printf_buffer+strlen("0x")) ); - testcase = nextdownl(testcase); + testcase = detail::nextdownl(testcase); } for (int precision = -1; precision < 50; precision++) @@ -173,7 +184,7 @@ test02() *result.ptr = '\0'; char nearby_buffer[50000]; { - const long double smaller = nextdownl(value); + const long double smaller = detail::nextdownl(value); result = to_chars(begin(nearby_buffer), end(nearby_buffer), smaller, fmt); VERIFY( result.ec == errc{} ); @@ -182,7 +193,7 @@ test02() } { - long double larger = nextupl(value); + long double larger = detail::nextupl(value); result = to_chars(begin(nearby_buffer), end(nearby_buffer), larger, fmt); VERIFY( result.ec == errc{} ); -- 2.30.0