![]() |
|
Message-ID: <20250408222526.GA2724612@port70.net> Date: Wed, 9 Apr 2025 00:25:26 +0200 From: Szabolcs Nagy <nsz@...t70.net> To: Lénárd Szolnoki <cpp@...ardszolnoki.com> Cc: musl@...ts.openwall.com Subject: Re: strtod doesn't set errno to ERANGE for slightly out-of-range hex float * Lénárd Szolnoki <cpp@...ardszolnoki.com> [2025-03-24 10:55:36 +0000]: > Hi, > > #include <stdlib.h> > #include <assert.h> > #include <errno.h> > > int main() { > const char* const input = "0x1.fffffffffffff8p+1023"; > double ret = strtod(input, NULL); > assert(errno == ERANGE); > } > > The input is slightly out of range, DBL_MAX is 1.fffffffffffffp+1023 (one > fewer binary 1 in the mantissa). > > The assert fails with musl libc, passes with glibc. this looks valid (might depend on long double representation). the overflow threshold is not calculated precisely for the hexfloat case. __floatscan returns an in range long double value that is rounded to inf by strtod, but there is no overflow check there. i guess hexfloat overflow check should be fixed. > > musl version: 1.2.5 (as shipped in Debian sid) > > Regards, > Lénárd Szolnoki
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.