From patchwork Mon Dec 12 13:55:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kyrill Tkachov X-Patchwork-Id: 87693 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1651086qgi; Mon, 12 Dec 2016 05:55:39 -0800 (PST) X-Received: by 10.84.128.78 with SMTP id 72mr185527083pla.110.1481550939085; Mon, 12 Dec 2016 05:55:39 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id d5si43423131pgj.17.2016.12.12.05.55.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Dec 2016 05:55:39 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-444165-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-444165-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-444165-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=jiaGNrexOLceOsTY6eJ9oCEKHTze5f2xjtBbyVsF24r7n0 AKBch7Q4qUYQr0zyIk/eai0i3EbByYwxJXSJ/pZIWNki9D0sNtkb7znWCx8tqIT3 NWhZmqLp8Yloikjf4wqWDPS16pr+BaBPDVPYbeTLfP8OXBQyKgTR2lV4b9XJY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=hgk0yJH5yBTQ0tyPspRX4tquLGI=; b=nrzucIyigjK1w8ZiKRVJ DwzIa6a7nqJYzWYT5pDtfxiADauEmuKT0UsZ7gSY5qVHXNfd1huUwqiRwjYwyX0B /lsT6j16WPfCO4MkdjvAJSI2HFoJ5BDdYttz7ZWDyz/ors6haULipPyOJE4BKqd9 cVs8EERLuhIEvtGQ8JZbehk= Received: (qmail 102315 invoked by alias); 12 Dec 2016 13:55:23 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 102289 invoked by uid 89); 12 Dec 2016 13:55:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, KAM_LOTSOFHASH, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=UD:math.h, mathh, math.h, 20082016 X-Spam-User: qpsmtpd, 2 recipients X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Dec 2016 13:55:12 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 274D91596; Mon, 12 Dec 2016 05:55:08 -0800 (PST) Received: from [10.2.207.77] (e100706-lin.cambridge.arm.com [10.2.207.77]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A99F63F4F8; Mon, 12 Dec 2016 05:55:07 -0800 (PST) Message-ID: <584EAC3A.3070408@foss.arm.com> Date: Mon, 12 Dec 2016 13:55:06 +0000 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: "libstdc++@gcc.gnu.org" , GCC Patches Subject: [PATCH][libstdc++][testsuite] XFAIL tests relying on long double-to-string conversions on broken newlib Hi all, I've been investigating the execution failures of: 21_strings/basic_string/numeric_conversions/char/stod.cc 21_strings/basic_string/numeric_conversions/wchar_t/stod.cc 21_strings/basic_string/numeric_conversions/wchar_t/stold.cc 27_io/basic_ostream/inserters_arithmetic/char/hexfloat.cc on aarch64-none-elf, a newlib target. The reason they are failing is because they are converting a long double to a string using to_string before trying to convert it back into a number. to_string ends up calling a vsnprintf from the C library (newlib in this case) with the %Lf format to convert from long double. Unfortunately the %Lf format is broken in newlib for platforms where long double is not the same as double. It gives bogus results because newlib doesn't implement the long double variant of frexp (frexpl) which is needed to implement printf properly. So it ends up using frexp even on long doubles. This gives wrong results which causes these tests to fail. So this patch marks them as XFAIL and adds an effective target check for broken newlib versions. With this patch these tests appear as XFAIL on aarch64-none-elf. Ok for trunk? Thanks, Kyrill 2016-12-12 Kyrylo Tkachov * lib/target-supports.exp (check_effective_target_newlib_broken_long_double_io): New check. (check_effective_target_frexpl): Likewise. 2016-12-12 Kyrylo Tkachov * testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc: XFAIL run if newlib_broken_long_double_io. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc: Likewise. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/hexfloat.cc: Likewise. diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index bce181fd87b32d51edb9b62fef81ad4314f0d222..d6229392b1414a26fe000dd61cc75ec112453b5f 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -6765,6 +6765,17 @@ proc check_effective_target_newlib {} { }] } +# Some newlib versions don't provide a frexpl and instead depend +# on frexp to implement long double conversions in their printf-like +# functions. This leads to broken results. Detect such versions here. + +proc check_effective_target_newlib_broken_long_double_io {} { + if { [is-effective-target newlib] && ![is-effective-target frexpl] } { + return 1 + } + return 0 +} + # Return true if this is NOT a Bionic target. proc check_effective_target_non_bionic {} { @@ -7380,6 +7391,21 @@ proc check_effective_target_pow10 { } { } "-lm" ] } +# Return 1 if frexpl function exists. + +proc check_effective_target_frexpl { } { + return [check_runtime frexpl { + #include + int main () { + long double x; + int y; + x = frexpl (5.0, &y); + return 0; + } + } "-lm" ] +} + + # Return 1 if issignaling function exists. proc check_effective_target_issignaling {} { return [check_runtime issignaling { diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc index 7e7c1347eab51abef73865073dbb4129db71af48..088641130075add8346948f286cfc63de6637721 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc @@ -1,5 +1,6 @@ // { dg-do run { target c++11 } } // { dg-require-string-conversions "" } +// { dg-xfail-run-if "broken long double IO" { newlib_broken_long_double_io } "*" "" } // 2008-06-15 Paolo Carlini diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc index 15a4dcaddb46dc62df9f7c51c3c07c73823fccff..df39a50b9c8964f70db17a07caaf0f8a48eddbcf 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc @@ -1,5 +1,6 @@ // { dg-do run { target c++11 } } // { dg-require-string-conversions "" } +// { dg-xfail-run-if "broken long double IO" { newlib_broken_long_double_io } "*" "" } // 2008-06-15 Paolo Carlini diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc index 81735dd186617c0fe96c2334e5fab2cef6a07d4e..259dc65024833af576b5cba44942e996c41c1b0d 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc @@ -1,5 +1,7 @@ // { dg-do run { target c++11 } } // { dg-require-string-conversions "" } +// { dg-xfail-run-if "broken long double IO" { newlib_broken_long_double_io } "*" "" } + // 2008-06-15 Paolo Carlini // Copyright (C) 2008-2016 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc index 82b8c8bb84658d5b30b69fffbf7066940e44a460..3a95010945b25317619f34458905d540076a407a 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc @@ -1,5 +1,7 @@ // { dg-do run { target c++11 } } // { dg-require-string-conversions "" } +// { dg-xfail-run-if "broken long double IO" { newlib_broken_long_double_io } "*" "" } + // 2008-06-15 Paolo Carlini // Copyright (C) 2008-2016 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/hexfloat.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/hexfloat.cc index 364bc56d2faac10c19c673d1adcd0e7e986a777f..839037917c959905a11774854bb1ceb88c5559a4 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/hexfloat.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/hexfloat.cc @@ -1,6 +1,7 @@ // { dg-do run { target c++11 } } // { dg-require-string-conversions "" } // { dg-xfail-run-if "PR libstdc++/64054" { *-*-solaris* } } +// { dg-xfail-run-if "broken long double IO" { newlib_broken_long_double_io } "*" "" } // 2014-03-27 RĂ¼diger Sonderfeld // test the hexadecimal floating point inserters (facet num_put)