在 2026-6-16 10:02, Kirill Makurin 写道:
Hello,

While working on crt testcases changes, I was playing around with 
_set_error_mode, _set_abort_behavior, abort and assert to see how they behave 
in practice. I have discovered one inconsistency with MSVC: _[w]assert function 
must be declared without noreturn attribute.

I'm attaching a simple program (test.c) that I was using; you can use it to reproduce the 
issue: call _set_error_mode with _OUT_TO_MSGBOX and press "Ignore" when message 
box pops up.

What should happen is _[w]assert() returns and program continues until it hits 
abort(). Instead:

A. when compiled without -D_UNICODE (using _assert() wrapper for CRT's 
_assert()), or -O2 and higher, the program crashes.
B. otherwise, when compiled with -D_UNICODE, it prints "Great escape from 
assert!" which must not be printed from this code path.

This issue comes from the fact that we declare _[w]assert function with 
noreturn attribute, when in fact they can return; this behavior is 
documented[1]. Note that Microsoft headers declare _wassert without noreturn 
attribute (recent Microsoft headers do not expose _assert at all), so we should 
do the same.

Proposed fix is attached.

Yeah there's `noreturn` in Microsoft headers (since 2003 PSDK at least), so this change looks good. Pushed now.




--
Best regards,
LIU Hao

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to