在 2026-10-19 03:12, Peter Damianov via Mingw-w64-public 写道:
This works only in the static CRT; but I suspect `__mingw_fe_dfl_env` shouldn't be imported from a user DLL, so this part looks fine.fesetenv() treated any environment whose encoding is { 0, 0 } as FE_DFL_ENV. That is also how fegetenv() encodes a real environment with every exception unmasked, 64-bit x87 precision and round to nearest (for example x87 control word 0x0340 with MXCSR 0), so saving and restoring that environment silently reset it instead.FE_DFL_ENV is defined as &__mingw_fe_dfl_env, so compare the pointer, as glibc does with its own FE_DFL_ENV sentinel. So that a copy of *FE_DFL_ENV still selects the default environment rather than unmasking every exception, make __mingw_fe_dfl_env hold the real encoding of the startup environment on x86 (x87 control word 0x037f, MXCSR 0x1f80), which is what fegetenv() returns in that state. Extend t_fesetenv to save and restore such an environment, and to check that a copy of *FE_DFL_ENV still restores the defaults. Signed-off-by: Peter Damianov <[email protected]> --- mingw-w64-crt/misc/fesetenv.c | 13 ++++++++-- mingw-w64-crt/testcases/t_fesetenv.c | 38 ++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-)
I also wondered whether `feclearexcept()` should be called after `fesetenv()`, but POSIX says only 'the floating-point environment shall be inherited from the creating thread.' without anything about floating-point exceptions; so it's likely unnecessary.
I have pushed these patches now. Beside the code changes, your patches seem to have been sent from [email protected]; I suspect there's some misconfiguration in your client. I have fixed the authors (I did forget to correct it some times ago), so please also attach patches if it's appropriate.
-- Best regards, LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
