https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98829
Bug ID: 98829 Summary: Different results with -O3 and custom quiet NaN Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gnu at nemanjaboric dot com Target Milestone: --- Created attachment 50047 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50047&action=edit Example of the code giving different results Hi, see the attached code which generates the different code with -O3 (compiled with various GCC version). Two workarounds are commented in the code: to use `std::isnan` and to copy the source object. I couldn't find anything undefined that I'm doing here but I might be wrong. -ffast-math _is not_ used. Just -O3 yields different result: https://www.godbolt.org/z/nxPd8W