From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 842833857031; Tue, 11 Aug 2020 16:14:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 842833857031 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1597162462; bh=WEeo0waQJ2lxw9uHwx5srJeTCpZQ45gGbtFbFUA1krY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=lhrn1NxR6PwahJWr7Wak4o1YDjmwnWjqQdr59do98XuihKoXLSH7jn4mQbwGZiB5O yNxdvFeHs7FU90Itx7RASRaOWGTS0LCoGuvoLPsEH7rj4X9Xiqg+hNhZ+W6ShkmIie eHQ4PTCQABO8k3FGHckw6il964rYYDt+kt/iyUG8= From: "carlos at redhat dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/95450] [10/11 regression] Wrong long double folding Date: Tue, 11 Aug 2020 16:14:22 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 10.1.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: carlos at redhat dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Aug 2020 16:14:22 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95450 Carlos O'Donell changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |carlos at redhat dot com --- Comment #4 from Carlos O'Donell --- (In reply to Andreas Schwab from comment #0) > $ cat test-float.c > #include > #include >=20 > union gl_long_double_union > { > struct { double hi; double lo; } dd; > long double ld; > }; >=20 > const union gl_long_double_union gl_LDBL_MAX =3D > { { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL } }; > # undef LDBL_MAX > # define LDBL_MAX (gl_LDBL_MAX.ld) >=20 > int > main () > { > volatile long double m =3D LDBL_MAX; >=20 > assert (m + m > m); > } > $ gcc -O2 test-float.c > $ ./a.out > a.out: test-float.c:20: main: Assertion `m + m > m' failed. > Aborted >=20 > test-float.c.234t.optimized contains: >=20 > m =3D{v} 1.79769313486231580793728971405302307166001572487e+308; >=20 > but that evaluates to Inf. DBL_MAX is > 1.79769313486231570814527423731704e+308L. This comes from gnulib's use of lib/float.h. My question is why is gnulib using float.h on power? What makes the system float.h unsuable? Even if you fix this for your package including gnulib, the next failure you run into is this one: test-float.c:324: assertion 'x + x =3D=3D x' failed Aborted (core dumped) Extracting from the test case: #include #include #include #include int main (void) { int n =3D 107; volatile long double m =3D LDBL_MAX; volatile long double pow2_n =3D powl (2, n); volatile long double x =3D m + (m / pow2_n); printf ("n =3D %d\n", n); printf ("m =3D %Lf (%La)\n", m, m); printf ("pow2_n =3D %Lf (%La)\n", pow2_n, pow2_n); printf ("m / pow2_n =3D %Lf (%La)\n", (m / pow2_n), (m / pow2_n)); printf ("x =3D %Lf (%La)\n", x, x); if (x > m) assert (x + x =3D=3D x); return 0; } gcc -o ~/test-ldbl-max ~/test-ldbl-max.c -lm ~/test-ldbl-max n =3D 107 m =3D 179769313486231580793728971405301199252069012264752390332004544495176179865= 349768338004270583473493681874097135387894924752516923758125018237039690323= 659469736010689648748751591634331824498526377862231967249520608291850653495= 428451067676993116107021027413767397958053860876625383538022115414866471826= 801819648.000000 (0x1.fffffffffffff7ffffffffffff8p+1023) pow2_n =3D 162259276829213363391578010288128.000000 (0x1p+107) m / pow2_n =3D 110791393256022258121672422304912469437693132793791879897129506936320570316= 424474038910284450656740265424479952834202611867356284481158468301454503013= 710067897690156746809385507598551635354474728284958909822596007453203965161= 9564827101237983225846137075291097947344654582153216.000000 (0x1.fffffffffffff7ffffffffffff8p+916) x =3D 179769313486231580793728971405301199252069012264752390332004544495176179865= 349768338004270583473493681874097135387894924752516923758125018237039690323= 659469736010689648748751591634331824498526377862231967249520608291850653495= 428451067676993116107021027413767397958053860876625383538022115414866471826= 801819648.000000 (0x1.fffffffffffff7ffffffffffffcp+1023) test-ldbl-max: /root/test-ldbl-max.c:21: main: Assertion `x + x =3D=3D x' f= ailed. Aborted (core dumped) Is this just a function of double double? That there is something representable that is larger than LDBL_MAX, but isn= 't valid given the double-double rules?=