Recent version of MinGW need MINGW_HAS_SECURE_API to be defined to 1 in order to provide secure functions (like _wgetenv_s, used in th coreapi/global/global.cpp file).
Adding such definition in the correct files (currently: qtbase/qmakespecs/win32-g++/qmake.conf) will allow you to use recent 64bits version of MinGW (like the newen distro, which is likely up to date with Gcc versions).
Even if i undersand you cannot be completely up-to-date with all Gcc versions, passing from Gcc-5.3.0 (which is three year old for now) to a more recent version (like 7.2.0 or 7.3.0 like the nuwen distro) could be very profitable, since those version are automatiquely at least configured to use C++14.
And more: giving ability to compile application in 64bits mode could be benfic for everyone
Corrected files could look like those i join to this ticket (sorry if i don't provide a patch )