]> sourceware.org Git - glibc.git/commitdiff
Test errno setting on strtod overflow in tst-strtod-round
authorJoseph Myers <josmyers@redhat.com>
Wed, 14 Aug 2024 17:15:46 +0000 (17:15 +0000)
committerJoseph Myers <josmyers@redhat.com>
Wed, 14 Aug 2024 17:15:46 +0000 (17:15 +0000)
We have no tests that errno is set to ERANGE on overflow of
strtod-family functions (we do have some tests for underflow, in
tst-strtod-underflow).  Add such tests to tst-strtod-round.

Tested for x86_64.

stdlib/tst-strtod-round-skeleton.c

index 6fba4b522862cbb90bc2e8fff6163f8c927fcc4e..c3cc0201d4b1a062318a57d79cd837776b7ee55c 100644 (file)
@@ -21,6 +21,7 @@
    declared in the headers.  */
 #define _LIBC_TEST 1
 #define __STDC_WANT_IEC_60559_TYPES_EXT__
+#include <errno.h>
 #include <fenv.h>
 #include <float.h>
 #include <math.h>
@@ -205,7 +206,9 @@ struct test {
 #define GEN_ONE_TEST(FSUF, FTYPE, FTOSTR, LSUF, CSUF)          \
 {                                                              \
   feclearexcept (FE_ALL_EXCEPT);                               \
+  errno = 0;                                                   \
   FTYPE f = STRTO (FSUF) (s, NULL);                            \
+  int new_errno = errno;                                       \
   if (f != expected->FSUF                                      \
       || (copysign ## CSUF) (1.0 ## LSUF, f)                   \
         != (copysign ## CSUF) (1.0 ## LSUF, expected->FSUF))   \
@@ -254,6 +257,14 @@ struct test {
                printf ("ignoring this exception error\n");     \
            }                                                   \
        }                                                       \
+      if (overflow->FSUF && new_errno != ERANGE)               \
+       {                                                       \
+         printf (FNPFXS "to" #FSUF                             \
+                 " (" STRM ") left errno == %d,"               \
+                 " not %d (ERANGE)\n",                         \
+                 s, new_errno, ERANGE);                        \
+         result = 1;                                           \
+       }                                                       \
     }                                                          \
 }
 
This page took 0.042347 seconds and 5 git commands to generate.