aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Myers <josmyers@redhat.com>2024-08-14 17:15:46 +0000
committerArjun Shankar <arjun@redhat.com>2024-09-27 17:24:03 +0200
commit9bc76c7ca4d6022fd588c274d139813f99e04f35 (patch)
tree83b529cdf86d3a09c02c5399ce58a2694d22c77c
parent61b6464f8d72aef520ee769a2ae317b4f68d5e1d (diff)
downloadglibc-9bc76c7ca4d6022fd588c274d139813f99e04f35.zip
glibc-9bc76c7ca4d6022fd588c274d139813f99e04f35.tar.gz
glibc-9bc76c7ca4d6022fd588c274d139813f99e04f35.tar.bz2
Test errno setting on strtod overflow in tst-strtod-round
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. (cherry picked from commit 207d64feb26279e152c50744e3c37e68491aca99)
-rw-r--r--stdlib/tst-strtod-round-skeleton.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/stdlib/tst-strtod-round-skeleton.c b/stdlib/tst-strtod-round-skeleton.c
index 6fba4b5..c3cc020 100644
--- a/stdlib/tst-strtod-round-skeleton.c
+++ b/stdlib/tst-strtod-round-skeleton.c
@@ -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; \
+ } \
} \
}