From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14728 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Bug report: strtod drops LSB Date: Wed, 25 Sep 2019 11:51:51 -0400 Message-ID: <20190925155151.GV9017@brightrain.aerifal.cx> References: Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="43322"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) Cc: musl@lists.openwall.com To: Anastasios Original-X-From: musl-return-14744-gllmg-musl=m.gmane.org@lists.openwall.com Wed Sep 25 17:52:09 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 1iD9aK-000B3X-Of for gllmg-musl@m.gmane.org; Wed, 25 Sep 2019 17:52:08 +0200 Original-Received: (qmail 27662 invoked by uid 550); 25 Sep 2019 15:52:06 -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 26620 invoked from network); 25 Sep 2019 15:52:05 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:14728 Archived-At: On Wed, Sep 25, 2019 at 09:32:35AM -0500, Anastasios wrote: > Hello, > > Consider this program, strtod.c: > >     #include >     #include > >     int main() >     { >         printf("%lf\n", strtod("283686952306183", NULL)); >     } > > With current musl master from Git: > >     $ musl-gcc -static strtod.c -o a.musl >     $ ./a.musl >     283686952306176.000000 > > By comparison, with glibc: > >     $ gcc -static strtod.c -o a.glibc >     $ ./a.glibc >     283686952306183.000000 > > The correct binary representation of this float is > >     0x42f0203040506070 > > but musl strtod produces > >     0x42f0203040506000 > > i.e., it fails to set the LSB. I examined this while ruling out printf as the cause. I can't reproduce this. My test program for strtod shows, for the input "283686952306183": d: 283686952306183 [0x1.020304050607p+48] [42f0203040506070] I suspect you miscompiled musl, possibly by passing in CFLAGS (perhaps from defaults in your environment?) that break floating point semantics. We test for and refuse to build if __FAST_MATH__ is defined, but GCC only defines it if you use -ffast-math, not if you manually enable one or more of the individual broken options that -ffast-math enables. Alternatively, it's possible that you have a broken compiler version that miscompiles floating point code. Rich