Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 6 Sep 2022 14:13:11 +0200
From: Joakim Sindholt <>
Subject: Re: ecvt(0, 0, ...) is broken

On Tue, 6 Sep 2022 12:12:48 +0200, Gabriel Ravier <> wrote:
> Executing ecvt(0, 0, &decpt, &sign) results in musl returning 
> "000000000000000".
> This seems highly likely to be a bug considering that glibc returns "" 
> and I see no plausible reasoning for musl's behavior that could be 
> justified by the standard.

POSIX.1-2001 said:
> The ecvt() function shall convert value to a null-terminated string of
> ndigit digits (where ndigit is reduced to an unspecified limit
> determined by the precision of a double) and return a pointer to the
> string. The high-order digit shall be non-zero, unless the value is 0.

The first part would imply that ndigit=0 should return the string "" but
the second part makes no provision for a zero-digit-long string.
I would say ndigit=0 is UB.

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.