From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4E65F3858D20; Fri, 4 Feb 2022 19:02:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E65F3858D20 From: "vstinner at redhat dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/104389] New: HUGE_VAL * 0.0 is no longer a NaN Date: Fri, 04 Feb 2022 19:02:17 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vstinner 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: --- 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://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: Fri, 04 Feb 2022 19:02:17 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104389 Bug ID: 104389 Summary: HUGE_VAL * 0.0 is no longer a NaN Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: vstinner at redhat dot com Target Milestone: --- Created attachment 52352 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D52352&action=3Dedit Reproducer: huge_val_0_nan.c The Python project uses "HUGE_VAL * 0" to get a Not-a-Number (NaN) double value. Pseudo-code: #define Py_NAN (Py_HUGE_VAL * 0.) double my_nan(void) { return Py_NAN; } Until Fedora gcc-12.0.1-0.4.fc36.x86_64 (03182470d2d2b272f06500184acab6b8ed78d8ad), it worked well. With Fedora gcc-12.0.1-0.5.fc36.x86_64 (fb6057a2be99e071993fb54a5d338ab0febba8ff), my_nan() now returns zero (0.0). Try attached huge_val_0_nan.c. gcc-12.0.1-0.5.fc36.x86_64 output: --- (1) Compute HUGE_VAL * 0 in the C compiler isnan? 0 bytes: [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] (2) Compute HUGE_VAL * 0 at runtime isnan? 1 bytes: [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfffffff8, 0xffffffff] --- gcc-11.2.1-7.fc35.x86_64 output: --- (1) Compute HUGE_VAL * 0 in the C compiler isnan? 1 bytes: [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfffffff8, 0x7f] (2) Compute HUGE_VAL * 0 at runtime isnan? 1 bytes: [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfffffff8, 0xffffffff] --- In Python, Py_NAN is defined as "#define Py_NAN (Py_HUGE_VAL * 0.)" at: https://github.com/python/cpython/blob/bf95ff91f2c1fc5a57190491f9ccdc63458b= 089e/Include/pymath.h#L60 FYI diff of the Fedora package between -4 and -5, the most important part if the Git commit which changed ;-) https://src.fedoraproject.org/rpms/gcc/c/398138b5f3809856b98eb4241b3c9f70da= 3fce9b?branch=3Drawhide=