https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120910
Bug ID: 120910 Summary: spurious underflow Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: zimmerma+gcc at loria dot fr Target Milestone: --- Created attachment 61775 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61775&action=edit source file to reproduce the bug with the attached code, gcc emits a spurious underflow. This was reported by Maxence Ponsardin. zimmerma@biscotte:/tmp/core-math$ gcc -O1 -march=x86-64-v3 -frounding-math /tmp/e.c -lm && ./a.out underflow: 16 y=inf clang 19.1.7 does not emit any underflow: zimmerma@biscotte:/tmp/core-math$ clang -O1 -march=x86-64-v3 -frounding-math /tmp/e.c -lm && ./a.out underflow: 0 y=inf My guess is that the branch prediction precomputes the result of the cast from 0x1p-25f to _Float16, which would give an underflow, but in the end this branch is not taken.