Hi, Pali Rohár wrote: > Second thing is broken return value of feenableexcept() and > fedisableexcept(). They have to return bits of OLD enabled exceptions > (not new after change).
Yes, that is how the functions are specified in https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/baselib-feenableexcept.html https://sourceware.org/glibc/manual/latest/html_node/Control-Functions.html https://man7.org/linux/man-pages/man3/feenableexcept.3.html > The problem is that the current implementation for changing register to > the same value cause disabled of all exception interrupts. This is > caused by usage of FSTENV/FNSTENV instruction which automatically > disable all exceptions. Yes, this is a pitfall. The exceptions are masked until the next FLDENV or FLDCW instruction. The NetBSD people made the same mistake in their fetestexcept() implementation. > With all these 3 mingw-w64 changes, those gltests tests are passing. Nice! > For improving debugging of gltests fenv tests, I would suggest to extend > test-fenv-except-trapping-1.c test with additional assert, which will > check that the feenableexcept() call correctly enabled the exception "a": > > --- gltests/test-fenv-except-trapping-1.c 2026-04-06 16:13:27.000000000 > +0200 > +++ gltests/test-fenv-except-trapping-1.c 2026-04-11 00:01:49.297039481 > +0200 > @@ -60,6 +60,7 @@ main () > fputs ("Skipping test: trapping floating-point exceptions are > not supported on this machine.\n", stderr); > return 77; > } > + ASSERT (fegetexcept () == uint_to_exceptions (a)); > ASSERT (fedisableexcept (uint_to_exceptions (b)) > == uint_to_exceptions (a)); > /* Check fegetexcept. */ Sounds good. Applied as follows: 2026-04-10 Bruno Haible <[email protected]> fenv-exceptions-trapping tests: Make test more debugging friendly. Suggested by Pali Rohár <[email protected]>. * tests/test-fenv-except-trapping-1.c (main): Add an assertion. diff --git a/tests/test-fenv-except-trapping-1.c b/tests/test-fenv-except-trapping-1.c index 341411bbdd..c9250248f9 100644 --- a/tests/test-fenv-except-trapping-1.c +++ b/tests/test-fenv-except-trapping-1.c @@ -60,6 +60,10 @@ main () fputs ("Skipping test: trapping floating-point exceptions are not supported on this machine.\n", stderr); return 77; } + /* Check fegetexcept. */ + ASSERT (fegetexcept () == uint_to_exceptions (a)); + /* Check the return value of fedisableexcept. It should be consistent + with fegetexcept. */ ASSERT (fedisableexcept (uint_to_exceptions (b)) == uint_to_exceptions (a)); /* Check fegetexcept. */
