Programs fail to execute with a runtime error when locale is set.
The following codes fail both for english and greek (haven't checked with other locales) with the run-time error: "terminate called after throwing an instance of 'std::runtime_error' what(): locale::facet::_S_create_c_locale name not valid Aborted". The codes that fail: 1. #include <iostream> #include <locale> #include <string> int main() { using namespace std; locale::global(locale("en_US")); wcin.imbue(locale("greek")); wcout.imbue(locale("greek")); wstring ws; wcin>> ws; wcout<< ws<< endl; } 2. #include <iostream> #include <locale> #include <string> int main() { using namespace std; ios_base::sync_with_stdio(false); wcin.imbue(locale("greek")); wcout.imbue(locale("greek")); wstring ws; wcin>> ws; wcout<< ws<< endl; } 3. #include <iostream> #include <locale> #include <string> int main() { using namespace std; wcin.imbue(locale("greek")); wcout.imbue(locale("greek")); wstring ws; wcin>> ws; wcout<< ws<< endl; } It fails for files too: 4. #include <locale> #include <string> #include <fstream> int main() { using namespace std; wstring ws= L"Test"; wofstream file("filename.txt"); file.imbue(locale("greek")); if(file.is_open()) file<< ws; } The bug is serious, I can't save unicode texts in my programs! -- Summary: Programs fail to execute with a runtime error when locale is set Product: gcc Version: 4.2.3 Status: UNCONFIRMED Severity: blocker Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ivranos at freemail dot gr http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37673