summaryrefslogtreecommitdiff
path: root/mpfr-impl.h
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2009-01-20 22:12:11 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2009-01-20 22:12:11 +0000
commitb70e087b548cc505fdff58c3b35ddca7778127e5 (patch)
tree7ba1971e4ec1859177aabcf25029eb9b4807b016 /mpfr-impl.h
parentf10eb82bbb59289ac94f924eb770257b88967215 (diff)
downloadmpfr-b70e087b548cc505fdff58c3b35ddca7778127e5.tar.gz
Fixed bug reported by Chris Saunders: if _GMP_IEEE_FLOATS is defined,
the build of tset_ld.c fails because DOUBLE_ISNAN expects a lvalue. * mpfr-impl.h: documented that for such macros, the argument must be a lvalue, and always make sure that it is a lvalue (so that a failure doesn't depend on the environment). * tests/tset_ld.c: fixed the bug. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@5880 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'mpfr-impl.h')
-rw-r--r--mpfr-impl.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/mpfr-impl.h b/mpfr-impl.h
index 45a095640..2721d6d5e 100644
--- a/mpfr-impl.h
+++ b/mpfr-impl.h
@@ -395,7 +395,7 @@ static double double_zero = 0.0;
# define DBL_NEG_ZERO (-0.0)
#endif
-/* for x of type ieee_double_extract */
+/* Note: the argument x must be a lvalue of type double. */
#if _GMP_IEEE_FLOATS
typedef union ieee_double_extract Ieee_double_extract;
@@ -407,16 +407,18 @@ typedef union ieee_double_extract Ieee_double_extract;
((((Ieee_double_extract *)&(x))->s.manl != 0) || \
(((Ieee_double_extract *)&(x))->s.manh != 0)))
#else
-# define DOUBLE_ISINF(x) ((x) > DBL_MAX || (x) < -DBL_MAX)
+/* Below, the &(x) == &(x) allows to make sure that x is a lvalue
+ without (probably) any warning from the compiler. */
+# define DOUBLE_ISINF(x) (&(x) == &(x) && ((x) > DBL_MAX || (x) < -DBL_MAX))
# ifdef MPFR_NANISNAN
/* Avoid MIPSpro / IRIX64 / gcc -ffast-math (incorrect) optimizations.
The + must not be replaced by a ||. With gcc -ffast-math, NaN is
regarded as a positive number or something like that; the second
test catches this case. */
# define DOUBLE_ISNAN(x) \
- (!((((x) >= 0.0) + ((x) <= 0.0)) && -(x)*(x) <= 0.0))
+ (&(x) == &(x) && !((((x) >= 0.0) + ((x) <= 0.0)) && -(x)*(x) <= 0.0))
# else
-# define DOUBLE_ISNAN(x) ((x) != (x))
+# define DOUBLE_ISNAN(x) (&(x) == &(x) && (x) != (x))
# endif
#endif