The std::locale constructor explicit locale(const char* _Locname, category _Cat = all);will temporarily set the global locale to the locale being constructed.This occurs in "C:\Program Files\Microsoft Visual Studio 9.0\VC\crt\src\locale.cpp" line 186, method "_Locinfo::_Locinfo_Addcats(_Locinfo *pLocinfo, int cat, const char *locname)" (called from method "_Locinfo::_Locinfo_ctor()"): else if (cat == _M_ALL) oldlocname = setlocale(LC_ALL, locname);This is set back to the previous value in file "C:\Program Files\Microsoft Visual Studio 9.0\VC\crt\src\locale0.cpp" line 262, method "_Locinfo::_Locinfo_dtor(_Locinfo *pLocinfo)" { // destroy a _Locinfo object, revert locale if (0 < pLocinfo->_Oldlocname.size()) setlocale(LC_ALL, pLocinfo->_Oldlocname.c_str()); }This is problematic because any code accessing the global locale in another thread has a chance to temporarily use the wrong locale, namely the one being constructed on the other thread.We have experienced this problem in the field.I could not find any specification of the C++ standard that would allow the std::locale constructor to touch the global locale.Note: I tested this only with the multi-threaded runtime DLL because that's what our products need to link with.
Version
Please wait...