diff --git a/sysdeps/i386/fpu/fesetexcept.c b/sysdeps/i386/fpu/fesetexcept.c index 6eeb5ab5b0..8c93264b0c 100644 --- a/sysdeps/i386/fpu/fesetexcept.c +++ b/sysdeps/i386/fpu/fesetexcept.c @@ -46,15 +46,20 @@ fesetexcept (int excepts) fenv_t temp; __asm__ ("fnstenv %0" : "=m" (*&temp)); + /* Note: fnstenv masks all floating-point exceptions until the fldenv + or fldcw below. */ /* Clear or set relevant flags. */ temp.__status_word |= temp.__status_word & excepts; if ((~temp.__control_word) & excepts) - /* Setting the exception flags may trigger a trap (at the next - floating-point instruction, but that does not matter). - ISO C23 (7.6.4.4) does not allow it. */ - return -1; + { + /* Setting the exception flags may trigger a trap (at the next + floating-point instruction, but that does not matter). + ISO C23 ยง 7.6.4.4 does not allow it. */ + __asm__ volatile ("fldcw %0" : : "m" (*&temp.__control_word)); + return -1; + } /* Store the new status word (along with the rest of the environment). */ __asm__ ("fldenv %0" : : "m" (*&temp));