In pre_c_init, there's a statement intending to set the value of the _commode variable in the CRT to the value of the _commode variable defined in the local module (with a default fallback in libmingw32.a), like this:
* __MINGW_IMP_SYMBOL(_commode) = _commode; However, due to the earlier _commode define, #define _commode (* __MINGW_IMP_SYMBOL(_commode)) the assignment statement evaluates to a no-op assigment. Fix this by removing the define (and the duplicate declaration of __MINGW_IMP_SYMBOL(_commode).) Normally that whole assignment is optimized out altogether - but if crtexe.c is built without optimization, the accesses to __imp__commode are left intact. This restores the intent of the code, initializing the CRT's _commode variable, just like _fmode is initailized. Signed-off-by: Martin Storsjö <[email protected]> --- mingw-w64-crt/crt/crtexe.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mingw-w64-crt/crt/crtexe.c b/mingw-w64-crt/crt/crtexe.c index 528957542..bea6c04a2 100644 --- a/mingw-w64-crt/crt/crtexe.c +++ b/mingw-w64-crt/crt/crtexe.c @@ -54,8 +54,7 @@ extern int * __MINGW_IMP_SYMBOL(_commode); #undef _fmode extern int _fmode; -extern int * __MINGW_IMP_SYMBOL(_commode); -#define _commode (* __MINGW_IMP_SYMBOL(_commode)) +extern int _commode; extern int _dowildcard; extern _CRTIMP void __cdecl _initterm(_PVFV *, _PVFV *); -- 2.17.1 _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
