https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94168
--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> --- Thank you for the analysis and suggested patch. The original source code looks like this: #ifdef WINDOWS static std::string wide_string_to_string(const std::wstring & wstr) { int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)§wstr.size(), NULL, 0, NULL, NULL); std::string str( size_needed, 0 ); WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &str[0], size_needed, NULL, NULL); return str; } #endif