Follow @Openwall on Twitter for new release announcements and other news
[<prev] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20261012211053.GQ23438@brightrain.aerifal.cx>
Date: Mon, 12 Oct 2026 17:10:54 -0400
From: Rich Felker <dalias@...c.org>
To: Song-Jiang <songjiang@...gxue.org>
Cc: musl@...ts.openwall.com
Subject: Re: strtod/strtof: errno not set to ERANGE when result rounds
 up to a subnormal power of two

On Mon, Oct 12, 2026 at 03:53:14PM +0000, Song-Jiang wrote:
> musl's strtod and strtof do not set errno to ERANGE when an inexact
> decimal input rounds *up* to a subnormal power of two. The returned
> value is correct; only errno is missing. ERANGE is set for every other
> underflowing input I tried: subnormal results that are not powers of
> two, subnormal powers of two reached by rounding *down* (e.g. "5e-324"),
> and inputs just below the smallest normal. Inexact inputs that round up
> to the smallest normal itself (e.g. "2.2250738585072014e-308")
> correctly stay silent, so this is not the usual FLT_MIN/DBL_MIN case.

Attached patch should fix this.

Rich

View attachment "0001-strtod-fix-incorrect-logic-detecting-underflow.patch" of type "text/plain" (2556 bytes)

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.