https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95115
--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by Xi Ruoyao <xry...@gcc.gnu.org>: https://gcc.gnu.org/g:8799006ab889b8bd8a6d6fbea5ddb64a17b2e541 commit r11-9531-g8799006ab889b8bd8a6d6fbea5ddb64a17b2e541 Author: Xi Ruoyao <xry...@mengyan1223.wang> Date: Mon Jan 31 01:15:20 2022 +0800 fold-const: do not fold NaN result from non-NaN operands [PR95115] These operations should raise an invalid operation exception at runtime. So they should not be folded during compilation unless -fno-trapping-math is used. gcc/ PR middle-end/95115 * fold-const.c (const_binop): Do not fold NaN result from non-NaN operands. gcc/testsuite * gcc.dg/pr95115.c: New test. (cherry picked from commit 34afa19d29c5bf0b0f504e4d0aca4e9a8bc82c5c)