aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2006-03-16 16:34:05 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2006-03-16 16:34:05 +0000
commita47564c87c482e932230f440463c9c1a962e66d8 (patch)
treea2a57c56bccf00dd8cdef7eec61b9feab32f21c8
parent349f4ea14a4b563b86ef48a3f4dde6643ae91226 (diff)
downloadgcc-a47564c87c482e932230f440463c9c1a962e66d8.zip
gcc-a47564c87c482e932230f440463c9c1a962e66d8.tar.gz
gcc-a47564c87c482e932230f440463c9c1a962e66d8.tar.bz2
re PR middle-end/21781 (real.c incorrectly values zero with a large exponent)
PR middle-end/21781 * real.c (real_from_string): If the mantissa is zero, don't bother parsing the exponent as the result should always be zero. * gcc.dg/real-const-1.c: New test case. From-SVN: r112136
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/real.c9
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/real-const-1.c4
4 files changed, 24 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b7870e3..3dac824 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2006-03-16 Roger Sayle <roger@eyesopen.com>
+
+ PR middle-end/21781
+ * real.c (real_from_string): If the mantissa is zero, don't bother
+ parsing the exponent as the result should always be zero.
+
2006-03-16 Andreas Krebbel <krebbel1@de.ibm.com>
* simplify-rtx.c (simplify_plus_minus): Simplify within CONST terms.
diff --git a/gcc/real.c b/gcc/real.c
index c4b6479..1e1083f 100644
--- a/gcc/real.c
+++ b/gcc/real.c
@@ -1862,6 +1862,11 @@ real_from_string (REAL_VALUE_TYPE *r, const char *str)
str++;
}
}
+
+ /* If the mantissa is zero, ignore the exponent. */
+ if (!cmp_significand_0 (r))
+ goto underflow;
+
if (*str == 'p' || *str == 'P')
{
bool exp_neg = false;
@@ -1934,6 +1939,10 @@ real_from_string (REAL_VALUE_TYPE *r, const char *str)
}
}
+ /* If the mantissa is zero, ignore the exponent. */
+ if (r->cl == rvc_zero)
+ goto underflow;
+
if (*str == 'e' || *str == 'E')
{
bool exp_neg = false;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6b093ac..90dc700 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2006-03-16 Roger Sayle <roger@eyesopen.com>
+
+ PR middle-end/21781
+ * gcc.dg/real-const-1.c: New test case.
+
2006-03-15 Geoffrey Keating <geoffk@apple.com>
* g++.old-deja/g++.other/init18.C: New.
diff --git a/gcc/testsuite/gcc.dg/real-const-1.c b/gcc/testsuite/gcc.dg/real-const-1.c
new file mode 100644
index 0000000..3e2bbfd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/real-const-1.c
@@ -0,0 +1,4 @@
+/* PR middle-end/21781. */
+/* { dg-do compile } */
+
+int f[.0e200000000 == 0?1:-1];