summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicențiu Ciorbaru <vicentiu@mariadb.org>2018-01-09 09:05:48 +0200
committerVicențiu Ciorbaru <vicentiu@mariadb.org>2018-01-09 09:05:48 +0200
commite35af66223454d4df9bab6af3e8230f37fc5296c (patch)
tree13576400b4d718fd3b59a350c47bbd979b9dfbf3
parentc5ac1f953bf6d4279967f03a8343303f715ad7aa (diff)
downloadmariadb-git-bb-10.3-vicentiu-dtoa.tar.gz
Workaround for dtoa.cbb-10.3-vicentiu-dtoa
There is no obvious reason why multiplying by 1.0 helps solve a precision problem on gcc-7 or clang-5, but it does work. Casting to ulong however makes the problem come up again. Windows warns about loss of precision, so to quiet warnings until an appropriate fix is implemented, ifdef 2 versions of the code.
-rw-r--r--strings/dtoa.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/strings/dtoa.c b/strings/dtoa.c
index 7b560227026..f27a91c3920 100644
--- a/strings/dtoa.c
+++ b/strings/dtoa.c
@@ -1290,7 +1290,17 @@ static double ratio(Bigint *a, Bigint *b)
dval(&db)= b2d(b, &kb);
k= ka - kb + 32*(a->wds - b->wds);
if (k > 0)
- word0(&da)+= (ULong)(k*Exp_msk1 * 1.0);
+#ifdef _WIN32
+ word0(&da)+= k*Exp_msk1;
+#else
+ /*
+ TODO(cvicentiu)
+ This is a temporary fix for a possible clang-5 / gcc-7 bug. This
+ should not be required but it makes double results in the end
+ be predictable.
+ */
+ word0(&da)+= k*Exp_msk1 * 1.0;
+#endif
else
{
k= -k;