diff options
Diffstat (limited to 'stdio-common')
-rw-r--r-- | stdio-common/tstdiomisc.c | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/stdio-common/tstdiomisc.c b/stdio-common/tstdiomisc.c index fa07aa5a89..5c046bbef3 100644 --- a/stdio-common/tstdiomisc.c +++ b/stdio-common/tstdiomisc.c @@ -47,8 +47,14 @@ t2 (void) } volatile double qnanval; -volatile double infval; volatile long double lqnanval; +/* A sNaN is only guaranteed to be representable in variables with static (or + thread-local) storage duration. */ +static volatile double snanval = __builtin_nans(""); +static volatile double msnanval = -__builtin_nans(""); +static volatile long double lsnanval = __builtin_nansl(""); +static volatile long double lmsnanval = -__builtin_nansl(""); +volatile double infval; volatile long double linfval; @@ -74,6 +80,19 @@ F (void) printf ("expected \"-nan -NAN -nan -NAN -nan -NAN -nan -NAN\", got \"%s\"\n", buf); + snprintf (buf, sizeof buf, "%a %A %e %E %f %F %g %G", + snanval, snanval, snanval, snanval, + snanval, snanval, snanval, snanval); + result |= strcmp (buf, "nan NAN nan NAN nan NAN nan NAN") != 0; + printf ("expected \"nan NAN nan NAN nan NAN nan NAN\", got \"%s\"\n", buf); + + snprintf (buf, sizeof buf, "%a %A %e %E %f %F %g %G", + msnanval, msnanval, msnanval, msnanval, + msnanval, msnanval, msnanval, msnanval); + result |= strcmp (buf, "-nan -NAN -nan -NAN -nan -NAN -nan -NAN") != 0; + printf ("expected \"-nan -NAN -nan -NAN -nan -NAN -nan -NAN\", got \"%s\"\n", + buf); + infval = DBL_MAX * DBL_MAX; snprintf (buf, sizeof buf, "%a %A %e %E %f %F %g %G", @@ -102,6 +121,19 @@ F (void) wbuf); swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), L"%a %A %e %E %f %F %g %G", + snanval, snanval, snanval, snanval, + snanval, snanval, snanval, snanval); + result |= wcscmp (wbuf, L"nan NAN nan NAN nan NAN nan NAN") != 0; + printf ("expected L\"nan NAN nan NAN nan NAN nan NAN\", got L\"%S\"\n", wbuf); + + swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), L"%a %A %e %E %f %F %g %G", + msnanval, msnanval, msnanval, msnanval, + msnanval, msnanval, msnanval, msnanval); + result |= wcscmp (wbuf, L"-nan -NAN -nan -NAN -nan -NAN -nan -NAN") != 0; + printf ("expected L\"-nan -NAN -nan -NAN -nan -NAN -nan -NAN\", got L\"%S\"\n", + wbuf); + + swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), L"%a %A %e %E %f %F %g %G", infval, infval, infval, infval, infval, infval, infval, infval); result |= wcscmp (wbuf, L"inf INF inf INF inf INF inf INF") != 0; printf ("expected L\"inf INF inf INF inf INF inf INF\", got L\"%S\"\n", wbuf); @@ -128,6 +160,19 @@ F (void) printf ("expected \"-nan -NAN -nan -NAN -nan -NAN -nan -NAN\", got \"%s\"\n", buf); + snprintf (buf, sizeof buf, "%La %LA %Le %LE %Lf %LF %Lg %LG", + lsnanval, lsnanval, lsnanval, lsnanval, + lsnanval, lsnanval, lsnanval, lsnanval); + result |= strcmp (buf, "nan NAN nan NAN nan NAN nan NAN") != 0; + printf ("expected \"nan NAN nan NAN nan NAN nan NAN\", got \"%s\"\n", buf); + + snprintf (buf, sizeof buf, "%La %LA %Le %LE %Lf %LF %Lg %LG", + lmsnanval, lmsnanval, lmsnanval, lmsnanval, + lmsnanval, lmsnanval, lmsnanval, lmsnanval); + result |= strcmp (buf, "-nan -NAN -nan -NAN -nan -NAN -nan -NAN") != 0; + printf ("expected \"-nan -NAN -nan -NAN -nan -NAN -nan -NAN\", got \"%s\"\n", + buf); + linfval = LDBL_MAX * LDBL_MAX; snprintf (buf, sizeof buf, "%La %LA %Le %LE %Lf %LF %Lg %LG", @@ -160,6 +205,21 @@ F (void) swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), L"%La %LA %Le %LE %Lf %LF %Lg %LG", + lsnanval, lsnanval, lsnanval, lsnanval, + lsnanval, lsnanval, lsnanval, lsnanval); + result |= wcscmp (wbuf, L"nan NAN nan NAN nan NAN nan NAN") != 0; + printf ("expected L\"nan NAN nan NAN nan NAN nan NAN\", got L\"%S\"\n", wbuf); + + swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), + L"%La %LA %Le %LE %Lf %LF %Lg %LG", + lmsnanval, lmsnanval, lmsnanval, lmsnanval, + lmsnanval, lmsnanval, lmsnanval, lmsnanval); + result |= wcscmp (wbuf, L"-nan -NAN -nan -NAN -nan -NAN -nan -NAN") != 0; + printf ("expected L\"-nan -NAN -nan -NAN -nan -NAN -nan -NAN\", got L\"%S\"\n", + wbuf); + + swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), + L"%La %LA %Le %LE %Lf %LF %Lg %LG", linfval, linfval, linfval, linfval, linfval, linfval, linfval, linfval); result |= wcscmp (wbuf, L"inf INF inf INF inf INF inf INF") != 0; |