crt: Fix the initialization of the _commode variable 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ö <martin@martin.st>
diff --git a/mingw-w64-crt/crt/crtexe.c b/mingw-w64-crt/crt/crtexe.c index 5289575..bea6c04 100644 --- a/mingw-w64-crt/crt/crtexe.c +++ b/mingw-w64-crt/crt/crtexe.c
@@ -54,8 +54,7 @@ #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 *);