OS system msvcrt40.dll and msvcrt.dll libraries since Windows Vista, UCRT
library, versioned msvcr80.dll libraries and new have semi-broken _assert()
function which do not print anything to stderr in case the stderr FILE*
stream was set to translated UTF-8/UTF-16 mode (_O_U8TEXT or _O_U16TEXT or
_O_U16TEXT). This is because _assert() function is using fprintf() for
writing to stderr and it is limitation of fprintf() function that it does
not work on streams configured in one of those modes. Only fwprintf()
function can be used on FILE* stream in that mode. Add a workaround for
_assert() function. Implement a small mingw-w64 wrapper around the DLL
_assert() function and change mode to _O_TEXT before calling _assert().
Import symbol name is renamed to __msvcrt_assert and in def file is defined
with DATA keyword which prevent having function with __msvcrt_assert name.
mingw-w64 wrapper calls directly function via its import name.
---
mingw-w64-crt/Makefile.am | 2 +
.../api-ms-win-crt-runtime-l1-1-0.def.in | 2 +-
mingw-w64-crt/lib-common/msvcr120_app.def.in | 2 +-
mingw-w64-crt/lib-common/msvcrt.def.in | 2 +-
.../lib-common/ucrtbase-common.def.in | 2 +-
mingw-w64-crt/lib32/crtdll.def.in | 2 +-
mingw-w64-crt/lib32/msvcr100.def.in | 2 +-
mingw-w64-crt/lib32/msvcr100d.def.in | 2 +-
mingw-w64-crt/lib32/msvcr110.def.in | 2 +-
mingw-w64-crt/lib32/msvcr110d.def.in | 2 +-
mingw-w64-crt/lib32/msvcr120.def.in | 2 +-
mingw-w64-crt/lib32/msvcr120d.def.in | 2 +-
mingw-w64-crt/lib32/msvcr40d.def.in | 2 +-
mingw-w64-crt/lib32/msvcr70.def.in | 2 +-
mingw-w64-crt/lib32/msvcr70d.def.in | 2 +-
mingw-w64-crt/lib32/msvcr71.def.in | 2 +-
mingw-w64-crt/lib32/msvcr71d.def.in | 2 +-
mingw-w64-crt/lib32/msvcr80.def.in | 2 +-
mingw-w64-crt/lib32/msvcr80d.def.in | 2 +-
mingw-w64-crt/lib32/msvcr90.def.in | 2 +-
mingw-w64-crt/lib32/msvcr90d.def.in | 2 +-
mingw-w64-crt/lib32/msvcrt10.def.in | 2 +-
mingw-w64-crt/lib32/msvcrt20.def.in | 2 +-
mingw-w64-crt/lib32/msvcrt40.def.in | 2 +-
mingw-w64-crt/lib32/msvcrtd.def.in | 2 +-
mingw-w64-crt/lib64/msvcr100.def.in | 2 +-
mingw-w64-crt/lib64/msvcr100d.def.in | 2 +-
mingw-w64-crt/lib64/msvcr110.def.in | 2 +-
mingw-w64-crt/lib64/msvcr110d.def.in | 2 +-
mingw-w64-crt/lib64/msvcr120.def.in | 2 +-
mingw-w64-crt/lib64/msvcr120d.def.in | 2 +-
mingw-w64-crt/lib64/msvcr80.def.in | 2 +-
mingw-w64-crt/lib64/msvcr80d.def.in | 2 +-
mingw-w64-crt/lib64/msvcr90.def.in | 2 +-
mingw-w64-crt/lib64/msvcr90d.def.in | 2 +-
mingw-w64-crt/libarm32/msvcr110.def.in | 2 +-
mingw-w64-crt/libarm32/msvcr110d.def.in | 2 +-
mingw-w64-crt/libarm32/msvcr120.def.in | 2 +-
mingw-w64-crt/libarm32/msvcr120d.def.in | 2 +-
mingw-w64-crt/misc/_assert.c | 30 ++++++++++
mingw-w64-crt/testcases/Makefile.am | 1 +
mingw-w64-crt/testcases/t_assert.c | 56 +++++++++++++++++++
mingw-w64-headers/crt/assert.h | 2 +-
43 files changed, 128 insertions(+), 39 deletions(-)
create mode 100644 mingw-w64-crt/misc/_assert.c
create mode 100644 mingw-w64-crt/testcases/t_assert.c
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index acb5f5fb2779..08f48e7de858 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -173,6 +173,7 @@ src_msvcrt_common=\
include/mingw-wchar.h \
misc/__mingw_mbrtowc_cp.c \
misc/__mingw_wcrtomb_cp.c \
+ misc/_assert.c \
misc/_onexit.c \
misc/mbrlen.c \
misc/mbrtowc.c \
@@ -433,6 +434,7 @@ src_ucrtbase=\
misc/__p__osver_emul.c \
misc/__initenv.c \
misc/__winitenv.c \
+ misc/_assert.c \
misc/_onexit.c \
misc/output_format.c \
misc/ucrt-access.c \
diff --git a/mingw-w64-crt/lib-common/api-ms-win-crt-runtime-l1-1-0.def.in
b/mingw-w64-crt/lib-common/api-ms-win-crt-runtime-l1-1-0.def.in
index 06a8f3790bf6..2eaf2bd0f225 100644
--- a/mingw-w64-crt/lib-common/api-ms-win-crt-runtime-l1-1-0.def.in
+++ b/mingw-w64-crt/lib-common/api-ms-win-crt-runtime-l1-1-0.def.in
@@ -24,7 +24,7 @@ __threadid
__wcserror
__wcserror_s
; DATA set manually
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_beginthread
_beginthreadex
_c_exit
diff --git a/mingw-w64-crt/lib-common/msvcr120_app.def.in
b/mingw-w64-crt/lib-common/msvcr120_app.def.in
index a1fc7dc6e4cd..63cea1a7a7c6 100644
--- a/mingw-w64-crt/lib-common/msvcr120_app.def.in
+++ b/mingw-w64-crt/lib-common/msvcr120_app.def.in
@@ -1179,7 +1179,7 @@ _aligned_offset_recalloc
_aligned_realloc
_aligned_recalloc
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib-common/msvcrt.def.in
b/mingw-w64-crt/lib-common/msvcrt.def.in
index e597adad5efe..b06215cb3a9a 100644
--- a/mingw-w64-crt/lib-common/msvcrt.def.in
+++ b/mingw-w64-crt/lib-common/msvcrt.def.in
@@ -530,7 +530,7 @@ F_I386(_adj_fptan)
F_I386(_adjust_fdiv DATA)
_aexit_rtn DATA
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atoi64
_atoldbl
diff --git a/mingw-w64-crt/lib-common/ucrtbase-common.def.in
b/mingw-w64-crt/lib-common/ucrtbase-common.def.in
index c0a273e0f280..4f705bd65cd2 100644
--- a/mingw-w64-crt/lib-common/ucrtbase-common.def.in
+++ b/mingw-w64-crt/lib-common/ucrtbase-common.def.in
@@ -246,7 +246,7 @@ _aligned_realloc
F_DEBUG(_aligned_realloc_dbg)
_aligned_recalloc
F_DEBUG(_aligned_recalloc_dbg)
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib32/crtdll.def.in
b/mingw-w64-crt/lib32/crtdll.def.in
index d44d6d3885c6..13886adf597a 100644
--- a/mingw-w64-crt/lib32/crtdll.def.in
+++ b/mingw-w64-crt/lib32/crtdll.def.in
@@ -110,7 +110,7 @@ _acmdln DATA == _acmdln_dll
_aexit_rtn_dll DATA
_aexit_rtn DATA == _aexit_rtn_dll
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_basemajor_dll DATA
_baseminor_dll DATA
_baseversion_dll DATA
diff --git a/mingw-w64-crt/lib32/msvcr100.def.in
b/mingw-w64-crt/lib32/msvcr100.def.in
index b8f183bf0e11..9462a248cd4f 100644
--- a/mingw-w64-crt/lib32/msvcr100.def.in
+++ b/mingw-w64-crt/lib32/msvcr100.def.in
@@ -730,7 +730,7 @@ _aligned_offset_recalloc
_aligned_realloc
_aligned_recalloc
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib32/msvcr100d.def.in
b/mingw-w64-crt/lib32/msvcr100d.def.in
index 7dad2cc0f0be..d5e658e61a35 100644
--- a/mingw-w64-crt/lib32/msvcr100d.def.in
+++ b/mingw-w64-crt/lib32/msvcr100d.def.in
@@ -777,7 +777,7 @@ _aligned_realloc_dbg
_aligned_recalloc
_aligned_recalloc_dbg
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib32/msvcr110.def.in
b/mingw-w64-crt/lib32/msvcr110.def.in
index aa94393e4c01..210809f326fc 100644
--- a/mingw-w64-crt/lib32/msvcr110.def.in
+++ b/mingw-w64-crt/lib32/msvcr110.def.in
@@ -854,7 +854,7 @@ _aligned_offset_recalloc
_aligned_realloc
_aligned_recalloc
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib32/msvcr110d.def.in
b/mingw-w64-crt/lib32/msvcr110d.def.in
index 8c82e6ac08bf..fe19620d6eaf 100644
--- a/mingw-w64-crt/lib32/msvcr110d.def.in
+++ b/mingw-w64-crt/lib32/msvcr110d.def.in
@@ -901,7 +901,7 @@ _aligned_realloc_dbg
_aligned_recalloc
_aligned_recalloc_dbg
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib32/msvcr120.def.in
b/mingw-w64-crt/lib32/msvcr120.def.in
index 692846a5c328..1b179c5e85e7 100644
--- a/mingw-w64-crt/lib32/msvcr120.def.in
+++ b/mingw-w64-crt/lib32/msvcr120.def.in
@@ -865,7 +865,7 @@ _aligned_offset_recalloc
_aligned_realloc
_aligned_recalloc
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib32/msvcr120d.def.in
b/mingw-w64-crt/lib32/msvcr120d.def.in
index 9d6d6cb2495f..d03181759a74 100644
--- a/mingw-w64-crt/lib32/msvcr120d.def.in
+++ b/mingw-w64-crt/lib32/msvcr120d.def.in
@@ -912,7 +912,7 @@ _aligned_realloc_dbg
_aligned_recalloc
_aligned_recalloc_dbg
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib32/msvcr40d.def.in
b/mingw-w64-crt/lib32/msvcr40d.def.in
index 1590e659077b..bf2603eb1e38 100644
--- a/mingw-w64-crt/lib32/msvcr40d.def.in
+++ b/mingw-w64-crt/lib32/msvcr40d.def.in
@@ -1081,7 +1081,7 @@ _adj_fprem1
_adj_fptan
_adjust_fdiv DATA
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atoldbl
_beep
diff --git a/mingw-w64-crt/lib32/msvcr70.def.in
b/mingw-w64-crt/lib32/msvcr70.def.in
index ec64df727c37..4f536dbdf9ac 100644
--- a/mingw-w64-crt/lib32/msvcr70.def.in
+++ b/mingw-w64-crt/lib32/msvcr70.def.in
@@ -258,7 +258,7 @@ _aligned_offset_malloc
_aligned_offset_realloc
_aligned_realloc
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atoi64
_atoldbl
diff --git a/mingw-w64-crt/lib32/msvcr70d.def.in
b/mingw-w64-crt/lib32/msvcr70d.def.in
index 408f1e9194ce..a871a3ad27d1 100644
--- a/mingw-w64-crt/lib32/msvcr70d.def.in
+++ b/mingw-w64-crt/lib32/msvcr70d.def.in
@@ -292,7 +292,7 @@ _aligned_offset_realloc_dbg
_aligned_realloc
_aligned_realloc_dbg
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atoi64
_atoldbl
diff --git a/mingw-w64-crt/lib32/msvcr71.def.in
b/mingw-w64-crt/lib32/msvcr71.def.in
index 6e3f54069999..1d16b1c7b8d7 100644
--- a/mingw-w64-crt/lib32/msvcr71.def.in
+++ b/mingw-w64-crt/lib32/msvcr71.def.in
@@ -251,7 +251,7 @@ _aligned_offset_malloc
_aligned_offset_realloc
_aligned_realloc
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atoi64
_atoldbl
diff --git a/mingw-w64-crt/lib32/msvcr71d.def.in
b/mingw-w64-crt/lib32/msvcr71d.def.in
index 7f70c52095a2..8d9c8557f45a 100644
--- a/mingw-w64-crt/lib32/msvcr71d.def.in
+++ b/mingw-w64-crt/lib32/msvcr71d.def.in
@@ -285,7 +285,7 @@ _aligned_offset_realloc_dbg
_aligned_realloc
_aligned_realloc_dbg
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atoi64
_atoldbl
diff --git a/mingw-w64-crt/lib32/msvcr80.def.in
b/mingw-w64-crt/lib32/msvcr80.def.in
index 96116ac33248..885c49cd3214 100644
--- a/mingw-w64-crt/lib32/msvcr80.def.in
+++ b/mingw-w64-crt/lib32/msvcr80.def.in
@@ -355,7 +355,7 @@ _aligned_offset_malloc
_aligned_offset_realloc
_aligned_realloc
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib32/msvcr80d.def.in
b/mingw-w64-crt/lib32/msvcr80d.def.in
index c34f7a55152d..072a22e5182c 100644
--- a/mingw-w64-crt/lib32/msvcr80d.def.in
+++ b/mingw-w64-crt/lib32/msvcr80d.def.in
@@ -416,7 +416,7 @@ _aligned_realloc_dbg
_aligned_recalloc
_aligned_recalloc_dbg
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib32/msvcr90.def.in
b/mingw-w64-crt/lib32/msvcr90.def.in
index aba9b9726b6b..26babb2159e2 100644
--- a/mingw-w64-crt/lib32/msvcr90.def.in
+++ b/mingw-w64-crt/lib32/msvcr90.def.in
@@ -355,7 +355,7 @@ _aligned_offset_recalloc
_aligned_realloc
_aligned_recalloc
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib32/msvcr90d.def.in
b/mingw-w64-crt/lib32/msvcr90d.def.in
index 2c04ccd82d1e..134a44ca9050 100644
--- a/mingw-w64-crt/lib32/msvcr90d.def.in
+++ b/mingw-w64-crt/lib32/msvcr90d.def.in
@@ -406,7 +406,7 @@ _aligned_realloc_dbg
_aligned_recalloc
_aligned_recalloc_dbg
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib32/msvcrt10.def.in
b/mingw-w64-crt/lib32/msvcrt10.def.in
index 9d4db9f811e7..0e28d4467f5f 100644
--- a/mingw-w64-crt/lib32/msvcrt10.def.in
+++ b/mingw-w64-crt/lib32/msvcrt10.def.in
@@ -902,7 +902,7 @@ _access
_acmdln DATA
_aexit_rtn DATA
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_beginthread
_c_exit
_cabs
diff --git a/mingw-w64-crt/lib32/msvcrt20.def.in
b/mingw-w64-crt/lib32/msvcrt20.def.in
index 94dcdb2fab49..c8e686a7172e 100644
--- a/mingw-w64-crt/lib32/msvcrt20.def.in
+++ b/mingw-w64-crt/lib32/msvcrt20.def.in
@@ -937,7 +937,7 @@ __msvcrt20_wgetmainargs == __wgetmainargs ; msvcrt20.dll's
__wgetmainargs is inc
_abnormal_termination
_access
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atoldbl
_beep
diff --git a/mingw-w64-crt/lib32/msvcrt40.def.in
b/mingw-w64-crt/lib32/msvcrt40.def.in
index a061b15a8a65..8240ca7c7566 100644
--- a/mingw-w64-crt/lib32/msvcrt40.def.in
+++ b/mingw-w64-crt/lib32/msvcrt40.def.in
@@ -1055,7 +1055,7 @@ _adj_fprem1
_adj_fptan
_adjust_fdiv DATA
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atoldbl
_beep
diff --git a/mingw-w64-crt/lib32/msvcrtd.def.in
b/mingw-w64-crt/lib32/msvcrtd.def.in
index 36e9fa45eda0..a269f05579a6 100644
--- a/mingw-w64-crt/lib32/msvcrtd.def.in
+++ b/mingw-w64-crt/lib32/msvcrtd.def.in
@@ -237,7 +237,7 @@ _adj_fptan
_adjust_fdiv DATA
_aexit_rtn DATA
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atoi64
_atoldbl
diff --git a/mingw-w64-crt/lib64/msvcr100.def.in
b/mingw-w64-crt/lib64/msvcr100.def.in
index 0b378d9f1ac2..ae0bf4949605 100644
--- a/mingw-w64-crt/lib64/msvcr100.def.in
+++ b/mingw-w64-crt/lib64/msvcr100.def.in
@@ -687,7 +687,7 @@ _aligned_offset_recalloc
_aligned_realloc
_aligned_recalloc
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib64/msvcr100d.def.in
b/mingw-w64-crt/lib64/msvcr100d.def.in
index 138a161d8c23..8dbf089c4337 100644
--- a/mingw-w64-crt/lib64/msvcr100d.def.in
+++ b/mingw-w64-crt/lib64/msvcr100d.def.in
@@ -732,7 +732,7 @@ _aligned_realloc_dbg
_aligned_recalloc
_aligned_recalloc_dbg
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib64/msvcr110.def.in
b/mingw-w64-crt/lib64/msvcr110.def.in
index f4abb6f79b81..7b45f6cf1667 100644
--- a/mingw-w64-crt/lib64/msvcr110.def.in
+++ b/mingw-w64-crt/lib64/msvcr110.def.in
@@ -813,7 +813,7 @@ _aligned_offset_recalloc
_aligned_realloc
_aligned_recalloc
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib64/msvcr110d.def.in
b/mingw-w64-crt/lib64/msvcr110d.def.in
index 16b66b597965..ca4d10f63e39 100644
--- a/mingw-w64-crt/lib64/msvcr110d.def.in
+++ b/mingw-w64-crt/lib64/msvcr110d.def.in
@@ -858,7 +858,7 @@ _aligned_realloc_dbg
_aligned_recalloc
_aligned_recalloc_dbg
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib64/msvcr120.def.in
b/mingw-w64-crt/lib64/msvcr120.def.in
index ce006671e818..594f7d390159 100644
--- a/mingw-w64-crt/lib64/msvcr120.def.in
+++ b/mingw-w64-crt/lib64/msvcr120.def.in
@@ -825,7 +825,7 @@ _aligned_offset_recalloc
_aligned_realloc
_aligned_recalloc
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib64/msvcr120d.def.in
b/mingw-w64-crt/lib64/msvcr120d.def.in
index ed72d726098b..e49ddcb460bc 100644
--- a/mingw-w64-crt/lib64/msvcr120d.def.in
+++ b/mingw-w64-crt/lib64/msvcr120d.def.in
@@ -870,7 +870,7 @@ _aligned_realloc_dbg
_aligned_recalloc
_aligned_recalloc_dbg
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib64/msvcr80.def.in
b/mingw-w64-crt/lib64/msvcr80.def.in
index b3787ba7d9af..1b392454fa37 100644
--- a/mingw-w64-crt/lib64/msvcr80.def.in
+++ b/mingw-w64-crt/lib64/msvcr80.def.in
@@ -298,7 +298,7 @@ _aligned_offset_malloc
_aligned_offset_realloc
_aligned_realloc
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib64/msvcr80d.def.in
b/mingw-w64-crt/lib64/msvcr80d.def.in
index e30a100d5cab..cef0095fd1df 100644
--- a/mingw-w64-crt/lib64/msvcr80d.def.in
+++ b/mingw-w64-crt/lib64/msvcr80d.def.in
@@ -353,7 +353,7 @@ _aligned_realloc_dbg
_aligned_recalloc
_aligned_recalloc_dbg
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib64/msvcr90.def.in
b/mingw-w64-crt/lib64/msvcr90.def.in
index ea71960598b1..4945d2f3902a 100644
--- a/mingw-w64-crt/lib64/msvcr90.def.in
+++ b/mingw-w64-crt/lib64/msvcr90.def.in
@@ -302,7 +302,7 @@ _aligned_offset_recalloc
_aligned_realloc
_aligned_recalloc
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/lib64/msvcr90d.def.in
b/mingw-w64-crt/lib64/msvcr90d.def.in
index 01d12ceaaa41..625dd229cefb 100644
--- a/mingw-w64-crt/lib64/msvcr90d.def.in
+++ b/mingw-w64-crt/lib64/msvcr90d.def.in
@@ -347,7 +347,7 @@ _aligned_realloc_dbg
_aligned_recalloc
_aligned_recalloc_dbg
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/libarm32/msvcr110.def.in
b/mingw-w64-crt/libarm32/msvcr110.def.in
index 095dcaf69834..6b56dd8eff58 100644
--- a/mingw-w64-crt/libarm32/msvcr110.def.in
+++ b/mingw-w64-crt/libarm32/msvcr110.def.in
@@ -807,7 +807,7 @@ _aligned_offset_recalloc
_aligned_realloc
_aligned_recalloc
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/libarm32/msvcr110d.def.in
b/mingw-w64-crt/libarm32/msvcr110d.def.in
index d14b0e8c6ba5..8bd6eaa82f40 100644
--- a/mingw-w64-crt/libarm32/msvcr110d.def.in
+++ b/mingw-w64-crt/libarm32/msvcr110d.def.in
@@ -852,7 +852,7 @@ _aligned_realloc_dbg
_aligned_recalloc
_aligned_recalloc_dbg
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/libarm32/msvcr120.def.in
b/mingw-w64-crt/libarm32/msvcr120.def.in
index 74e9f0e8993d..3b3efdfa91a5 100644
--- a/mingw-w64-crt/libarm32/msvcr120.def.in
+++ b/mingw-w64-crt/libarm32/msvcr120.def.in
@@ -799,7 +799,7 @@ _aligned_offset_recalloc
_aligned_realloc
_aligned_recalloc
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/libarm32/msvcr120d.def.in
b/mingw-w64-crt/libarm32/msvcr120d.def.in
index 6ccc5bb90a2d..9eee8b10b9e0 100644
--- a/mingw-w64-crt/libarm32/msvcr120d.def.in
+++ b/mingw-w64-crt/libarm32/msvcr120d.def.in
@@ -844,7 +844,7 @@ _aligned_realloc_dbg
_aligned_recalloc
_aligned_recalloc_dbg
_amsg_exit
-_assert
+__msvcrt_assert DATA == _assert ; mingw-w64 provides _assert() function as
wrapper around renamed __msvcrt_assert symbol
_atodbl
_atodbl_l
_atof_l
diff --git a/mingw-w64-crt/misc/_assert.c b/mingw-w64-crt/misc/_assert.c
new file mode 100644
index 000000000000..c0476a29eaad
--- /dev/null
+++ b/mingw-w64-crt/misc/_assert.c
@@ -0,0 +1,30 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <io.h>
+#include <fcntl.h>
+
+/* This is import symbol name for "_assert" from CRT DLL library */
+__MINGW_ATTRIB_NORETURN
+extern void (__cdecl *__MINGW_IMP_SYMBOL(__msvcrt_assert))(const char
*message, const char *file, unsigned line);
+
+__MINGW_ATTRIB_NORETURN
+void __cdecl _assert(const char *message, const char *file, unsigned line)
+{
+ /* Turn off _O_WTEXT, _O_U16TEXT or _O_U8TEXT mode on stderr stream
+ * by changing mode to _O_TEXT, because fprintf (called by __msvcrt_assert)
+ * does not work (and does nothing) on FILE* stream in some of those modes.
+ * Only fwprintf works with those modes, but _assert uses fprintf.
+ * Before changing the FILE* stream mode, it is required to flush buffers. */
+ FILE *stream = stderr; /* stderr expands to function call */
+ fflush(stream);
+ _setmode(fileno(stream), _O_TEXT);
+ __MINGW_IMP_SYMBOL(__msvcrt_assert)(message, file, line);
+}
+__MINGW_ATTRIB_NORETURN
+void (__cdecl *__MINGW_IMP_SYMBOL(_assert))(const char *message, const char
*file, unsigned line) = _assert;
diff --git a/mingw-w64-crt/testcases/Makefile.am
b/mingw-w64-crt/testcases/Makefile.am
index 889439141918..354f5dc37aa9 100644
--- a/mingw-w64-crt/testcases/Makefile.am
+++ b/mingw-w64-crt/testcases/Makefile.am
@@ -18,6 +18,7 @@ testcase_progs = \
t__stat_all \
t_aligned_alloc \
t_ansi_io \
+ t_assert \
t_btowc \
t_findfirst \
t_float \
diff --git a/mingw-w64-crt/testcases/t_assert.c
b/mingw-w64-crt/testcases/t_assert.c
new file mode 100644
index 000000000000..2c8ae251ccb9
--- /dev/null
+++ b/mingw-w64-crt/testcases/t_assert.c
@@ -0,0 +1,56 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <process.h>
+#include <io.h>
+#include <fcntl.h>
+
+int main(int argc, char *argv[]) {
+ if (argc != 2 || strcmp(argv[1], "assert_test") != 0) {
+ int exit_code;
+ int pipefd[2];
+ int back_errfd;
+ intptr_t process;
+ ssize_t size;
+ char buf[512];
+
+ assert(_pipe(pipefd, sizeof(buf), O_NOINHERIT) == 0);
+
+ /* set stderr fd to write side of pipe, will be used by _spawnl() */
+ assert((back_errfd = dup(STDERR_FILENO)) >= 0);
+ assert(dup2(pipefd[1], STDERR_FILENO) == 0);
+ assert(close(pipefd[1]) == 0);
+
+ process = _spawnl(_P_NOWAIT, _pgmptr, argv[0], "assert_test", NULL);
+
+ /* revert back stderr fd */
+ assert(dup2(back_errfd, STDERR_FILENO) == 0);
+ assert(close(back_errfd) == 0);
+
+ assert(process != -1);
+
+ size = read(pipefd[0], buf, sizeof(buf));
+ close(pipefd[0]);
+ assert(size > 0); /* some data were written by child process */
+ assert(strnlen(buf, sizeof(buf)) > 0);
+
+ /* wait until child process exits */
+ assert(_cwait(&exit_code, process, _WAIT_CHILD) == process);
+ assert(exit_code != 0);
+
+ return 0;
+ }
+
+ /* change stderr to translated UNICODE mode */
+ _setmode(fileno(stderr), _O_U8TEXT);
+
+ /* call assert, it prints to stderr, parent process will check that our
stderr is not empty */
+#if __MSVCRT_VERSION__ > 0x800
+ _set_abort_behavior(0, _CALL_REPORTFAULT); /* assert() will not call Dr.
Watson */
+#endif
+ assert(0);
+
+ /* assert(0) does not return, this process pass when returns non-zero */
+ return 0;
+}
diff --git a/mingw-w64-headers/crt/assert.h b/mingw-w64-headers/crt/assert.h
index a8cfb2e83e3e..bce9a57cfa9f 100644
--- a/mingw-w64-headers/crt/assert.h
+++ b/mingw-w64-headers/crt/assert.h
@@ -22,7 +22,7 @@ extern "C" {
#endif
_CRTIMP void __cdecl __MINGW_ATTRIB_NORETURN _wassert(const wchar_t
*_Message,const wchar_t *_File,unsigned _Line);
-_CRTIMP void __cdecl __MINGW_ATTRIB_NORETURN _assert (const char *_Message,
const char *_File, unsigned _Line);
+void __cdecl __MINGW_ATTRIB_NORETURN _assert (const char *_Message, const char
*_File, unsigned _Line);
#ifdef __cplusplus
}
--
2.20.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public