From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 238D8383E813; Tue, 26 May 2020 12:43:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 238D8383E813 From: "florian at schanda dot org.uk" To: glibc-bugs@sourceware.org Subject: [Bug math/26045] New: fmaxf(inf, nan) does not always work Date: Tue, 26 May 2020 12:43:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: math X-Bugzilla-Version: 2.28 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: florian at schanda dot org.uk X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 May 2020 12:43:11 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D26045 Bug ID: 26045 Summary: fmaxf(inf, nan) does not always work Product: glibc Version: 2.28 Status: UNCONFIRMED Severity: normal Priority: P2 Component: math Assignee: unassigned at sourceware dot org Reporter: florian at schanda dot org.uk Target Milestone: --- Created attachment 12570 --> https://sourceware.org/bugzilla/attachment.cgi?id=3D12570&action=3Ded= it example showing fmaxf does not always work Hi The gcc people sent me here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id= =3D95329 I believe the fmaxf function does not always work correctly (I am on Debian stable, amd64). The following piece of code produces the wrong output when compile with no optimisation (and hence fmaxf from libm is called): $ gcc bug.c -lm $ ./a.out max(-inf, nan) =3D nan max(-inf, nan) =3D -inf The code in question uses a special hand-crafted NaN: #include #include #include #include int main() { uint32_t bv =3D 0x7FACBA7E; // (0 11111111 01011001011101001111110) float a, b; a =3D -INFINITY; memcpy(&b, &bv, 4); printf("max(%f, %f) =3D %f\n", a, b, fmaxf(a, b)); b =3D NAN; printf("max(%f, %f) =3D %f\n", a, b, fmaxf(a, b)); } Thanks in advance, and good luck! :) --=20 You are receiving this mail because: You are on the CC list for the bug.=