From 0007fc9bdd1d9efcd52d07837f2cd085b5a8f58b Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Thu, 23 May 2013 18:00:10 +0200 Subject: [BZ #15522] strtod ("nan(N)") returning a sNaN in some cases --- stdlib/tst-strtod6.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'stdlib/tst-strtod6.c') diff --git a/stdlib/tst-strtod6.c b/stdlib/tst-strtod6.c index 1d87266..15e79fd 100644 --- a/stdlib/tst-strtod6.c +++ b/stdlib/tst-strtod6.c @@ -4,12 +4,13 @@ #include static int -do_test (void) +test (const char str[]) { - static const char str[] = "NaN(blabla)something"; char *endp; int result = 0; + puts (str); + double d = strtod (str, &endp); if (!isnan (d)) { @@ -64,5 +65,24 @@ do_test (void) return result; } +static int +do_test (void) +{ + int result = 0; + + result |= test ("NaN(blabla)something"); + result |= test ("NaN(1234)something"); + /* UINT32_MAX. */ + result |= test ("NaN(4294967295)something"); + /* UINT64_MAX. */ + result |= test ("NaN(18446744073709551615)something"); + /* The case of zero is special in that "something" has to be done to make the + mantissa different from zero, which would mean infinity instead of + NaN. */ + result |= test ("NaN(0)something"); + + return result; +} + #define TEST_FUNCTION do_test () #include "../test-skeleton.c" -- cgit v1.1