about summary refs log tree commit diff
path: root/stdlib/gen-tst-strtod-round.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix strtod overflow detection (bug 23279).Joseph Myers2018-06-131-7/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As shown by bug 23279, strtod's round_and_return has an off-by-one error in its overflow detection, only counting an exponent greater than MAX_EXP as overflowing when an exponent of MAX_EXP also means overflow (recall the ISO C definition of DBL_MAX_EXP etc. is based on a floating-point model where 2^exp is multiplied by a value in the interval [0.5, 1), so 2^MAX_EXP is not representable). For decimal arguments to strtod, a separate overflow check in the main implementation covers the case where the integer part of the argument (truncated to the nearest integer towards zero) has more than MAX_EXP bits, meaning that this issue in round_and_return only affects cases (arguments with absolute value strictly between the maximum representable value and 2^MAX_EXP) where overflow depends on the rounding mode; in such cases, the returned value would still have been correct on overflow but without the overflow exception being raised or errno being set to ERANGE. For hex float arguments, however, other cases can arise, as shown in bug 23279, where a value with exponent already set to MAX_EXP is passed into round_and_return and a result can wrongly end up being NaN, or infinity instead of the largest finite value. This patch fixes the off-by-one error, adds testing of overflow exceptions to the tst-strtod-round framework, and adds tests of these issues. Tested for x86_64. Also ran the tst-strtod-round tests for powerpc to make sure the new tests didn't introduce any new failures for IBM long double. [BZ #23279] * stdlib/strtod_l.c (round_and_return): Handle an exponent of MAX_EXP as overflowing. * stdlib/gen-tst-strtod-round.c (string_to_fp): Clear MPFR overflow flag. (round_str): Output also whether result overflows in each rounding mode. * stdlib/tst-strtod-round-data: Add more tests. * stdlib/tst-strtod-round-data.h: Regenerated. * stdlib/tst-strtod-round-skeleton.c (_XNTRY): Update comment. (TEST): Handle extra arguments for overflow flags. (struct test_overflow): New type. [!FE_OVERFLOW] (FE_OVERFLOW): Define to 0. (GEN_ONE_TEST): Clear all exceptions. Test overflow flag. (test_in_one_mode): Take argument with overflow information. (do_test): Update calls to test_in_one_mode.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2018-01-011-1/+1
| | | | | | | * All files with FSF copyright notices: Update copyright dates using scripts/update-copyrights. * locale/programs/charmap-kw.h: Regenerated. * locale/programs/locfile-kw.h: Likewise.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2017-01-011-1/+1
|
* Make strtod raise "inexact" exceptions (bug 19380).Joseph Myers2016-10-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | 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.
* Refactor tst-strtod-round.c for type-generic-nessPaul E. Murphy2016-05-251-25/+23
| | | | | Reduce much of the redundancy in this file, and attempt to coral the type specific stuff to ease adding an new type.
* Refactor tst-strtod-round.cPaul E. Murphy2016-05-241-21/+67
| | | | | | | | | | This file is partially generated. To make updates a little simpler, I have moved the generated code into a partially contained header to simplify regeneration. gen-tst-strtod-round.c now takes two, mandatory arguments. These arguments specify the input test data and the output destination, respectively.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2016-01-041-1/+1
|
* Update copyright dates with scripts/update-copyrights.Joseph Myers2015-01-021-1/+1
|
* Update copyright notices with scripts/update-copyrightsAllan McRae2014-01-011-1/+1
|
* Rework tst-strtod-round handling of inexact results.Joseph Myers2013-06-131-5/+5
|
* Update copyright notices with scripts/update-copyrights.Joseph Myers2013-01-021-1/+1
|
* Fix strtod test for values above maximum for IBM long double.Joseph Myers2012-09-061-1/+14
|
* Correctly handle Motorola extended float format in tst-strtod-roundAndreas Schwab2012-09-051-3/+6
|
* Fix strtod rounding (bug 3479).Joseph Myers2012-08-271-0/+131