public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc/azanella/clang] stdlib: Only enable strtod_l asserts if SIZE_MAX == UINTMAX_MAX Date: Fri, 9 Feb 2024 17:31:28 +0000 (GMT) [thread overview] Message-ID: <20240209173128.7E4883858407@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=fabaaf9f0a69739657b498cd19317c465f271b51 commit fabaaf9f0a69739657b498cd19317c465f271b51 Author: Adhemerval Zanella <adhemerval.zanella@linaro.org> Date: Tue Jul 26 08:38:48 2022 -0300 stdlib: Only enable strtod_l asserts if SIZE_MAX == UINTMAX_MAX clang on 32 bits where size_t is smaller than intmax_t emits: strtod_l.c:874:18: error: result of comparison of constant 9223372036854775807 with expression of type 'size_t' (aka 'unsigned int') is always true [-Werror,-Wtautological-constant-out-of-range-compare] assert (dig_no <= (uintmax_t) INTMAX_MAX); ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ ../assert/assert.h:106:11: note: expanded from macro 'assert' if (expr) \ ^~~~ So only enable the assert iff SIZE_MAX == UINTMAX_MAX. Diff: --- stdlib/strtod_l.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c index be515ce659..d271ed0034 100644 --- a/stdlib/strtod_l.c +++ b/stdlib/strtod_l.c @@ -871,7 +871,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group, c = *++cp; } } + +#if SIZE_MAX == UINTMAX_MAX assert (dig_no <= (uintmax_t) INTMAX_MAX); +#endif /* Remember start of exponent (if any). */ expp = cp; @@ -901,16 +904,20 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group, { if (exp_negative) { +#if SIZE_MAX == UINTMAX_MAX assert (int_no <= (uintmax_t) (INTMAX_MAX + MIN_EXP - MANT_DIG) / 4); +#endif exp_limit = -MIN_EXP + MANT_DIG + 4 * (intmax_t) int_no; } else { if (int_no) { +#if SIZE_MAX == UINTMAX_MAX assert (lead_zero == 0 && int_no <= (uintmax_t) INTMAX_MAX / 4); +#endif exp_limit = MAX_EXP - 4 * (intmax_t) int_no + 3; } else if (lead_zero == (size_t) -1) @@ -921,8 +928,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group, } else { +#if SIZE_MAX == UINTMAX_MAX assert (lead_zero <= (uintmax_t) (INTMAX_MAX - MAX_EXP - 3) / 4); +#endif exp_limit = (MAX_EXP + 4 * (intmax_t) lead_zero + 3); @@ -933,16 +942,20 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group, { if (exp_negative) { +#if SIZE_MAX == UINTMAX_MAX assert (int_no <= (uintmax_t) (INTMAX_MAX + MIN_10_EXP - MANT_DIG)); +#endif exp_limit = -MIN_10_EXP + MANT_DIG + (intmax_t) int_no; } else { if (int_no) { +#if SIZE_MAX == UINTMAX_MAX assert (lead_zero == 0 && int_no <= (uintmax_t) INTMAX_MAX); +#endif exp_limit = MAX_10_EXP - (intmax_t) int_no + 1; } else if (lead_zero == (size_t) -1) @@ -953,8 +966,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group, } else { +#if SIZE_MAX == UINTMAX_MAX assert (lead_zero <= (uintmax_t) (INTMAX_MAX - MAX_10_EXP - 1)); +#endif exp_limit = MAX_10_EXP + (intmax_t) lead_zero + 1; } }
next reply other threads:[~2024-02-09 17:31 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-02-09 17:31 Adhemerval Zanella [this message] -- strict thread matches above, loose matches on Subject: below -- 2024-04-17 20:07 Adhemerval Zanella 2024-04-02 15:53 Adhemerval Zanella 2024-02-07 14:06 Adhemerval Zanella 2024-01-29 17:57 Adhemerval Zanella 2023-12-21 18:53 Adhemerval Zanella 2023-09-28 17:51 Adhemerval Zanella
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240209173128.7E4883858407@sourceware.org \ --to=azanella@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).