diff options
author | Joseph Myers <joseph@codesourcery.com> | 2016-10-28 00:40:23 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2016-10-28 00:40:23 +0000 |
commit | 4725d33eed118d69b8110285f7741cde9ddc8b4f (patch) | |
tree | be10b6e9854beb628d9b6021dab98ad03efebf4b /stdlib/gen-tst-strtod-round.c | |
parent | 61668b22f5d0efac44bbedad0e738faa6f0820ff (diff) | |
download | glibc-4725d33eed118d69b8110285f7741cde9ddc8b4f.tar glibc-4725d33eed118d69b8110285f7741cde9ddc8b4f.tar.gz glibc-4725d33eed118d69b8110285f7741cde9ddc8b4f.tar.bz2 glibc-4725d33eed118d69b8110285f7741cde9ddc8b4f.zip |
Make strtod raise "inexact" exceptions (bug 19380).
The strtod function should raise the "inexact" exception when its
result is inexact, but fails to do so except in the case of underflow
or overflow. This patch fixes it to do so for all inexact results.
tst-strtod-round is extended to test for this exception; the generator
is fixed to properly mark inexact results as such in the case where
the inexactness is from the mpfr_subnormalize step.
Tested for x86_64, x86 and powerpc.
[BZ #19380]
* stdlib/strtod_l.c (round_and_return): Force "inexact" exception
for inexact results.
* stdlib/gen-tst-strtod-round.c (string_to_fp): Return indication
of inexact result where mpfr_subnormalize is the only inexact
step.
* stdlib/tst-strtod-round-data.h: Regenerated.
* stdlib/tst-strtod-round-skeleton.c [!FE_INEXACT] (FE_INEXACT):
Define to 0.
(GEN_ONE_TEST): Test inexact exceptions raised are as expected.
Diffstat (limited to 'stdlib/gen-tst-strtod-round.c')
-rw-r--r-- | stdlib/gen-tst-strtod-round.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/stdlib/gen-tst-strtod-round.c b/stdlib/gen-tst-strtod-round.c index 1c2823f5be..85279090ee 100644 --- a/stdlib/gen-tst-strtod-round.c +++ b/stdlib/gen-tst-strtod-round.c @@ -50,12 +50,12 @@ string_to_fp (mpfr_t f, const char *s, mpfr_rnd_t rnd) mpfr_init2 (f2, 100000); int r0 = mpfr_strtofr (f2, s, NULL, 0, rnd); int r = mpfr_set (f, f2, rnd); - mpfr_subnormalize (f, r, rnd); + r |= mpfr_subnormalize (f, r, rnd); mpfr_clear (f2); return r0 | r; #else int r = mpfr_strtofr (f, s, NULL, 0, rnd); - mpfr_subnormalize (f, r, rnd); + r |= mpfr_subnormalize (f, r, rnd); return r; #endif } |