[Bug tree-optimization/109581] [13/14 Regression] Comparing with -HUGE_VAL wrong result
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109581 --- Comment #3 from Daniel Schürmann --- I can confirm that -fno-finite-math-only fixes the issue. Since this a new behavior in GCC 13 and it is also a hard to find issue, which took us many hours to dig it down, it would be nice tho have at least a warning something like: warning: comparison of infinity constant is always false. The issue is that this happens silently after a compiler update. It can cause real live issues, but is only recognized by a chance in a big code base. Is there a use case of explicit compare with HUGE_VAL/-HUGE_VAL and than disable it with -ffinite-math-only?
[Bug c/109581] New: Comparing with -HUGE_VAL wrong result
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109581 Bug ID: 109581 Summary: Comparing with -HUGE_VAL wrong result Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: daschuer at mixxx dot org Target Milestone: --- Comparing with -HUGE_VAL gives the wrong result with gcc (GCC) 13.0.1 20230401 (Red Hat 13.0.1-0). GCC 12.2 is and clang are not effected. This bug breaks Mixxx after compiling it on openSUSE Tumbleweed and Fedora 38 https://github.com/mixxxdj/mixxx/issues/11483 The workaround is to store -HUGE_VAL as a volatile first. This is a minimal code that demonstrates the issue: #include #include int main(int num) { long long rawInf = 0xfff0; volatile double inf = *(double*)(void*) if (inf == -HUGE_VAL) { puts("Success"); } else { puts("Error"); } return 0; } The following flags are used: -g -pipe -O3 -ffast-math -funroll-loops -fomit-frame-pointer -mtune=generic -Wall -Wextra -Wfloat-conversion -Werror=return-type Result GCC 12.2 and lower "Success" GCC 13.0 "Error" Details: https://godbolt.org/z/7bnb77hv4