https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86420
Bug ID: 86420 Summary: [9 regression] nextafter(0x1p-1022,0) is constant folded Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: nsz at gcc dot gnu.org Target Milestone: --- nextafterf(FLT_MIN,0), nextafter(DBL_MIN,0), nextafterl(LDBL_MIN,0) should signal the underflow exception (c99 annex F requirement), but now gcc constant folds them, this causes the following glibc test failures with gcc trunk: FAIL: math/bug-nextafter FAIL: math/bug-nexttoward for double f(void) { return __builtin_nextafter (0x1p-1022, 0); } on aarch64 with gcc -O2 -S -std=c11 -frounding-math i get f: mov x0, 4503599627370495 fmov d0, x0 ret with gcc-8 it is f: movi d1, #0 mov x0, 4503599627370496 fmov d0, x0 b nextafter gcc has no flag to say 'floating-point exceptions matter' (like -frounding-math for non-default rounding mode) so i think gcc should not do such optimizations in standard conform mode where users might test for exceptions.