public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/37673]  New: Programs fail to execute with a runtime error when locale is set
@ 2008-09-29 11:36 ivranos at freemail dot gr
  2008-09-29 11:38 ` [Bug c++/37673] " ivranos at freemail dot gr
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: ivranos at freemail dot gr @ 2008-09-29 11:36 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-09-30 10:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-29 11:36 [Bug c++/37673] New: Programs fail to execute with a runtime error when locale is set ivranos at freemail dot gr
2008-09-29 11:38 ` [Bug c++/37673] " ivranos at freemail dot gr
2008-09-29 11:47 ` paolo dot carlini at oracle dot com
2008-09-29 12:50 ` [Bug libstdc++/37673] " paolo dot carlini at oracle dot com
2008-09-29 13:28 ` ivranos at freemail dot gr
2008-09-29 13:39 ` paolo dot carlini at oracle dot com
2008-09-29 13:56 ` ivranos at freemail dot gr
2008-09-29 14:19 ` paolo dot carlini at oracle dot com
2008-09-30  9:53 ` ivranos at freemail dot gr
2008-09-30 10:23 ` paolo dot carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).