From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E9A743861001; Tue, 9 Mar 2021 19:01:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E9A743861001 From: "arek_koz at o2 dot pl" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/99494] New: isfinite gets optimized away with -Ofast Date: Tue, 09 Mar 2021 19:01:53 +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: 10.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: arek_koz at o2 dot pl 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 keywords bug_severity priority component assigned_to reporter target_milestone cf_gcchost cf_gcctarget cf_gccbuild 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: Tue, 09 Mar 2021 19:01:54 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99494 Bug ID: 99494 Summary: isfinite gets optimized away with -Ofast Product: gcc Version: 10.2.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: arek_koz at o2 dot pl Target Milestone: --- Host: x86_64-pc-linux-gnu Target: x86_64-pc-linux-gnu Build: x86_64-pc-linux-gnu Created attachment 50342 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D50342&action=3Dedit stripped _Py_HashDouble CPython compiled with -Ofast hangs forever on python -c 'hash(float("inf"))= '. Attached is a program based on stripped _Py_HashDouble from CPython sources. It should print 314159 when it reads an infinite number from the input. It always prints 1 instead (the function gets reduced to "return 1"). When replacing -Ofast with -O3, the problem is gone. Likely to appear on ot= her build/host/target configurations. Version: gcc (Gentoo 10.2.0-r5 p6) 10.2.0 Target architecture: x86_64 (generic) GCC is compiled to execute on: x86_64 (znver2) Invoked command: x86_64-pc-linux-gnu-gcc -Ofast -o bug bug.c My best guess: GCC -Ofast assumes that isfinite(v) is always true for any double v.=