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: 705045 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tckr627D1z9t2b for ; Tue, 13 Dec 2016 00:55:34 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="g4KtY55z"; dkim-atps=neutral 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=lE4dxx/YDIVu5fNJgcdP7bpcVfm7zyQgB8siyh+rPXx9hH 2ACrUksd7WBFR9gnqITD0ShoFGTCuTSifYQ0HBBJpw7dcELsA7zhzLSOcJ6vsd5C MldvGKRw+X3z+hgOFw7Im0lmHViy2ZL7PIwPapKirvCGH0yLdZiADz7+4awnM= 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=g4KtY55zlEtrjW+uZQKG stfwqUwqJHqxX0Zt/dBMJ+9MeVKUbJGztG9nEqvV/7xpOs2WCATtl8z3qYsz0nca G09cUsFgiE8nEd5ofYIpUrcepxcHHRUrzbCTc5senhXTLPqDt7Lppoft5XXCFN2E SUT4s9PIuq/bOEB4fVlO5Ik= 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)