aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAlexandre Oliva <oliva@adacore.com>2019-10-01 11:36:47 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2019-10-01 11:36:47 +0000
commit676e38c2a93311bc847c1034637efc935e527f8f (patch)
treeb71bee62329d42492f63b9ebfceb726d68dff4dc /gcc
parent31632e2c4327146ea8d21cff33adaa505b17d2bd (diff)
downloadgcc-676e38c2a93311bc847c1034637efc935e527f8f.zip
gcc-676e38c2a93311bc847c1034637efc935e527f8f.tar.gz
gcc-676e38c2a93311bc847c1034637efc935e527f8f.tar.bz2
Store float for pow result test
Optimizing gcc.dg/torture/pr41094.c, the compiler computes the constant value and short-circuits the whole thing. At -O0, however, on 32-bit x86, the call to pow() remains, and the program compares the returned value in a stack register, with excess precision, with the exact return value expected from pow(). If libm's pow() returns a slightly off result, the compare fails. If the value in the register is stored in a separate variable, so it gets rounded to double precision, and then compared, the compare passes. It's not clear that the test was meant to detect libm's reliance on rounding off the excess precision, but I guess it wasn't, so I propose this slight change that enables it to pass regardless of the slight inaccuracy of the C library in use. for gcc/testsuite/ChangeLog * gcc.dg/torture/pr41094.c: Introduce intermediate variable. From-SVN: r276404
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog2
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr41094.c3
2 files changed, 4 insertions, 1 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9923029..4f876e5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,7 @@
2019-10-01 Alexandre Oliva <oliva@adacore.com>
+ * gcc.dg/torture/pr41094.c: Introduce intermediate variable.
+
PR debug/91507
* gcc.dg/debug/dwarf2/array-0.c: New.
* gcc.dg/debug/dwarf2/array-1.c: New.
diff --git a/gcc/testsuite/gcc.dg/torture/pr41094.c b/gcc/testsuite/gcc.dg/torture/pr41094.c
index 2a4e961..9219a17 100644
--- a/gcc/testsuite/gcc.dg/torture/pr41094.c
+++ b/gcc/testsuite/gcc.dg/torture/pr41094.c
@@ -13,7 +13,8 @@ double foo(void)
int main()
{
- if (foo() != 2.0)
+ double r = foo ();
+ if (r != 2.0)
abort ();
return 0;
}