public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/99494] New: isfinite gets optimized away with -Ofast
@ 2021-03-09 19:01 arek_koz at o2 dot pl
  2021-03-09 19:11 ` [Bug c/99494] " schwab@linux-m68k.org
  2021-03-09 19:14 ` arek_koz at o2 dot pl
  0 siblings, 2 replies; 3+ messages in thread
From: arek_koz at o2 dot pl @ 2021-03-09 19:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99494

            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=50342&action=edit
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 other
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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/99494] isfinite gets optimized away with -Ofast
  2021-03-09 19:01 [Bug c/99494] New: isfinite gets optimized away with -Ofast arek_koz at o2 dot pl
@ 2021-03-09 19:11 ` schwab@linux-m68k.org
  2021-03-09 19:14 ` arek_koz at o2 dot pl
  1 sibling, 0 replies; 3+ messages in thread
From: schwab@linux-m68k.org @ 2021-03-09 19:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99494

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> ---
-Ofast implies -ffinite-math-only.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/99494] isfinite gets optimized away with -Ofast
  2021-03-09 19:01 [Bug c/99494] New: isfinite gets optimized away with -Ofast arek_koz at o2 dot pl
  2021-03-09 19:11 ` [Bug c/99494] " schwab@linux-m68k.org
@ 2021-03-09 19:14 ` arek_koz at o2 dot pl
  1 sibling, 0 replies; 3+ messages in thread
From: arek_koz at o2 dot pl @ 2021-03-09 19:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99494

--- Comment #2 from arek_koz at o2 dot pl ---
Sorry for trouble, my bad.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-09 19:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-09 19:01 [Bug c/99494] New: isfinite gets optimized away with -Ofast arek_koz at o2 dot pl
2021-03-09 19:11 ` [Bug c/99494] " schwab@linux-m68k.org
2021-03-09 19:14 ` arek_koz at o2 dot pl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).