On Wednesday 09 September 2026 04:30:52 Kirill Makurin wrote: > LIU Hao wrote: > > > 在 2026-9-9 12:19, Kirill Makurin 写道: > >> I'm redirecting this to the list and CC'ing Pali. > >> > >> Nikita Leontiev <[email protected]>: > >> > >>> Hello, > >>> > >>> FYI > >>> crt: remove noreturn attribute for _assert and > >>> _wassert<https://github.com/mingw-w64/mingw-w64/commit/ecf2328a328d11dec7044b40b2b5e93b5b2b9d9e> > >>> => abort is called from assert realization when ignore is > >>> used<https://sourceforge.net/p/mingw-w64/bugs/1031> > >> > >> Pali: Are you still in favor of keeping mingw-w64 _assert wrapper? Do you > >> have an idea how we can check whether `_fileno (stderr)` is a valid file > >> descriptor before doing `_setmode` tricks? > > > > You can check `_fileno (stderr) >= 0`. For a GUI application where no > > standard stream is attached, > > `_fileno (stderr)` yields -2. > > Thanks for a tip, that should do it. > > IIRC, Pali now is also in favor of removing mingw-w64 _assert wrapper. We > still disagree on whether `assert` macro should call `_wassert` > unconditionally. I'll wait for Pali's input. > > - Kirill Makurin
Hello, I read that bug report weeks ago and that was why I started investigating how to address the _assert issue. I discussed with Kirill and I promised to prepare some fix for that or at least some info. I spend some times on this, I tried to use setjmp with SEH unwind handlers (but that needed also DWARF one) and so... I realized that this is too complicated and it does not make sense to have such thing. So I would agree to simplify this code and rather completely remove the _assert wrapper from mingw-w64 and directly use _assert symbol from CRT DLL libraries. This should address reported bug and also other similar issues. What stay unfixed is: Direct _assert call by CONSOLE application which configured the stderr stream to _O_WTEXT, _O_U16TEXT or _O_U8TEXT will NOT print anything to stderr. assert just silently crash application without any error message on stderr. I think that we could ignore this problem for a few reasons: - benefit of simple _assert implementation is better (wrapper already introduced real bugs which caused worse issues) - _assert is still working as needed, it crashes application by default, but via signal can be trapped long jumping out; also in debug mode it can be skipped - it is highly unexpected that somebody will use NARROW assert together with WIDE stderr/print functions; most common is to use NARROW functions for everything or WIDE functions for everything For second thing about assert to _wassert. Like for any other functions which have both NARROW and WIDE variants, I would suggest to stay switching based on the _UNICODE macro, so also for assert. I do not like switching assert macro to _wassert unconditionally, mostly because of same reasons: - tchar based applications uses narrow/wide functions based on the _UNICODE macro, so narrow compile unit should use narrow functions (including assert one) - right now there is a direction moving from UTF-16 to UTF-8, hence to use narrow functions (not opposite) - for msvcrt builds, the _wassert requires larger code for resolving the _wassert symbol, with fallback to _assert code which has non trivial logic (and the point is to have assert logic for default builds simple) So unless somebody has better option what to do with _assert wrapper, I think that at least with Kirill we have consensus to remove the mingw-w64-crt/misc/_assert.c file completely. Any other opinion? _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
