From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14727 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: Bug report: strtod drops LSB Date: Wed, 25 Sep 2019 17:06:32 +0200 Message-ID: <20190925150632.GL22009@port70.net> References: Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="103516"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) To: musl@lists.openwall.com Original-X-From: musl-return-14743-gllmg-musl=m.gmane.org@lists.openwall.com Wed Sep 25 17:06:48 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1iD8sQ-000QkW-W5 for gllmg-musl@m.gmane.org; Wed, 25 Sep 2019 17:06:47 +0200 Original-Received: (qmail 16228 invoked by uid 550); 25 Sep 2019 15:06:44 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 16210 invoked from network); 25 Sep 2019 15:06:44 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:14727 Archived-At: * Anastasios [2019-09-25 09:32:35 -0500]: > Hello, >=20 > Consider this program, strtod.c: >=20 > =C2=A0 =C2=A0=C2=A0#include > =C2=A0 =C2=A0=C2=A0#include >=20 > =C2=A0 =C2=A0=C2=A0int main() > =C2=A0 =C2=A0=C2=A0{ > =C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0printf("%lf\n", strtod("28368695230= 6183", NULL)); > =C2=A0 =C2=A0=C2=A0} >=20 > With current musl master from Git: >=20 > =C2=A0 =C2=A0=C2=A0$ musl-gcc -static strtod.c -o a.musl > =C2=A0 =C2=A0 $ ./a.musl > =C2=A0 =C2=A0 283686952306176.000000 >=20 > By comparison, with glibc: >=20 > =C2=A0 =C2=A0 $ gcc -static strtod.c -o a.glibc > =C2=A0 =C2=A0 $ ./a.glibc > =C2=A0 =C2=A0 283686952306183.000000 >=20 works for me on both i486-linux-musl and aarch64-linux-musl. i have no idea what can cause such bug. can you try printf with %a and strtod(...)=3D=3D0x1.020304050607p+48 to see if it's printf %lf that goes wrong? > The correct binary representation of this float is >=20 > =C2=A0 =C2=A0 0x42f0203040506070 >=20 > but musl strtod produces >=20 > =C2=A0 =C2=A0 0x42f0203040506000 >=20 > i.e., it fails to set the LSB. I examined this while ruling out printf as= the cause.