Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <5a87ad28-d300-4c06-a60a-fa97a4d0d691@lenardszolnoki.com>
Date: Mon, 24 Mar 2025 10:55:36 +0000
From: Lénárd Szolnoki <cpp@...ardszolnoki.com>
To: musl@...ts.openwall.com
Subject: strtod doesn't set errno to ERANGE for slightly out-of-range hex
 float

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.

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.