While the <fenv.h> changes in mingw 13.0.0 are working all right,
in mingw 14.0.0 they added broken implementations of feenableexcept()
and fedisableexcept(). This leads to Gnulib test suite failures:

$ ./gnulib-tool --create-testdir --dir=../testdir1 \
                fenv-environment fenv-exceptions-state-c23 \
                fenv-exceptions-tracking-c23 fenv-exceptions-trapping \
                fenv-rounding

=>

FAIL: test-fenv-env-2
=====================

../../gltests/test-fenv-env-2.c:70: assertion 'fegetexcept () == 
(supports_trapping ? FE_DIVBYZERO : 0)' failed
FAIL test-fenv-env-2.exe (exit status: 3)

FAIL: test-fenv-env-3
=====================

../../gltests/test-fenv-env-3.c:70: assertion 'fegetexcept () == 
(supports_trapping ? FE_DIVBYZERO : 0)' failed
FAIL test-fenv-env-3.exe (exit status: 3)

FAIL: test-fenv-env-4
=====================

../../gltests/test-fenv-env-4.c:67: assertion 'fegetexcept () == 0' failed
FAIL test-fenv-env-4.exe (exit status: 3)

FAIL: test-fenv-env-5
=====================

../../gltests/test-fenv-env-5.c:67: assertion 'fegetexcept () == 0' failed
FAIL test-fenv-env-5.exe (exit status: 3)

FAIL: test-fenv-except-trapping-1
=================================

../../gltests/test-fenv-except-trapping-1.c:63: assertion 'fedisableexcept 
(uint_to_exceptions (b)) == uint_to_exceptions (a)' failed
FAIL test-fenv-except-trapping-1.exe (exit status: 3)


This patch adds a workaround: it overrides these broken implementations on
mingw.


2026-03-30  Bruno Haible  <[email protected]>

        fenv-exceptions-trapping: Work around mingw 14.0.0 bug.
        * m4/fenv-exceptions-trapping.m4 (gl_FENV_EXCEPTIONS_TRAPPING): Override
        feenableexcept, fedisableexcept also on mingw.

diff --git a/m4/fenv-exceptions-trapping.m4 b/m4/fenv-exceptions-trapping.m4
index dc388de27b..3679734775 100644
--- a/m4/fenv-exceptions-trapping.m4
+++ b/m4/fenv-exceptions-trapping.m4
@@ -1,5 +1,5 @@
 # fenv-exceptions-trapping.m4
-# serial 3
+# serial 4
 dnl Copyright (C) 2023-2026 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -20,6 +20,7 @@ AC_DEFUN_ONCE([gl_FENV_EXCEPTIONS_TRAPPING]
     dnl Fixed through
     dnl 
<https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=302949e2940a9da3f6364a1574619e621b7e1e71>.
     dnl Similarly on FreeBSD 12.2/arm, FreeBSD 12.2/arm64, NetBSD 10.0/arm64.
+    dnl On mingw 14.0.0, feenableexcept and fedisableexcept are broken as well.
     case "$host" in
       aarch64*-*-linux*)
         AC_CACHE_CHECK([whether feenableexcept works],
@@ -43,7 +44,8 @@ AC_DEFUN_ONCE([gl_FENV_EXCEPTIONS_TRAPPING]
           *) REPLACE_FEENABLEEXCEPT=1 ;;
         esac
         ;;
-      arm*-*-freebsd* | aarch64*-*-freebsd* | aarch64*-*-netbsd*)
+      arm*-*-freebsd* | aarch64*-*-freebsd* | aarch64*-*-netbsd* | \
+      *-*-mingw* | *-*-windows*)
         REPLACE_FEENABLEEXCEPT=1
         ;;
     esac




Reply via email to