diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2013-09-27 12:25:24 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2013-09-27 12:25:24 +0000 |
commit | 25550d032a48b015353f39bc585b109bdbb7f6ac (patch) | |
tree | 26466ca5c718fa698eff5232a5e7f0722c02e857 /src | |
parent | a2fa7f1d0db7b620266206125680c4ec0ee2513d (diff) | |
download | mpfr-25550d032a48b015353f39bc585b109bdbb7f6ac.tar.gz |
[src/mpfr-impl.h] With clang, disable division by zero using constants
due to a bug in its sanitizer and because IEEE 754 division by zero is
currently not properly supported.
With this change, the tget_d test no longer fails with:
clang -O2 -fsanitize=undefined -fno-sanitize-recover
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@8686 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src')
-rw-r--r-- | src/mpfr-impl.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/mpfr-impl.h b/src/mpfr-impl.h index d02f87821..02102119f 100644 --- a/src/mpfr-impl.h +++ b/src/mpfr-impl.h @@ -530,8 +530,16 @@ __MPFR_DECLSPEC extern const mpfr_t __gmpfr_four; #define MPFR_LIMBS_PER_FLT ((IEEE_FLT_MANT_DIG-1)/GMP_NUMB_BITS+1) /* Visual C++ doesn't support +1.0/0.0, -1.0/0.0 and 0.0/0.0 - at compile time. */ -#if defined(_MSC_VER) && defined(_WIN32) && (_MSC_VER >= 1200) + at compile time. + Clang with -fsanitize=undefined is a bit similar due to a bug: + http://llvm.org/bugs/show_bug.cgi?id=17381 + but even without its sanitizer, it may be better to use the + double_zero version until IEEE 754 division by zero is properly + supported: + http://llvm.org/bugs/show_bug.cgi?id=17000 +*/ +#if (defined(_MSC_VER) && defined(_WIN32) && (_MSC_VER >= 1200)) || \ + defined(__clang__) static double double_zero = 0.0; # define DBL_NAN (double_zero/double_zero) # define DBL_POS_INF ((double) 1.0/double_zero) |