Bug 32254 - std::runtime_error thrown by locale("")
Summary: std::runtime_error thrown by locale("")
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-08 07:18 UTC by thanate
Modified: 2008-09-29 14:17 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description thanate 2007-06-08 07:18:13 UTC
The following code compiles and run find using my system's
g++-4.1.3 but when compiled with g++-4.2.1 from SVN,
I get

terminate called after throwing an instance of 'std::runtime_error'
  what():  locale::facet::_S_create_c_locale name not valid
Aborted

//-----------------
#include <clocale>
#include <sstream>

int main ()
{
  std::wostringstream os;
  os.imbue(std::locale(""));
  return 0;
}
//-----------------
Comment 1 Paolo Carlini 2007-06-08 08:38:48 UTC
The only possible explanation is that, at build time, the configury didn't find the required localedata (at least "de_DE") or other tests failed, and the generic (instead of gnu) locale model has been selected. In that case the runtime_error is expected. Can you check that?
Comment 2 thanate 2007-06-08 23:40:04 UTC
umm... I don't know how to check for that. 
But I ran configure with --enable-clocale=gnu.
I posted my build log at
http://mathpost.asu.edu/~thanate/build.log
I'll keep the build dir for a while in case 
you need some more log files.
Comment 3 Paolo Carlini 2007-06-09 00:11:19 UTC
See this line in the Log:

> checking for C locale to use... generic

That means the configure-time tests for the gnu locale model are not ok and the generic locale model is selected instead, as a fallback. Can you investigate whether the 'de_DE' localedata is installed on your system? It's necessary for those checks. In order to do that you can, for example, run a small C program that does 'setlocale(LC_ALL, "de_DE")': it must return a non-NULL pointer. On linux, you can invoke 'localedef --list-archive'. (note that on 4.2.1 vs earlier releases, even if you pass --enable-clocale=gnu explicitely, the system is checked for actual support of the locale model, it cannot be forced: that may explain the unexpected behavior on your side).
Comment 4 thanate 2007-06-09 00:22:30 UTC
localedef --list-archive gave me only one line:

en_US.utf8

I think that's how I set up my system, with only one locale. 
Now I'm not sure why should I have to have de_DE installed
for locale("") to work. But if you want, I can install de_DE
and try again and report back.
Comment 5 Paolo Carlini 2007-06-09 00:26:52 UTC
Ok, that is it. That locale must be installed because old glibcs had a bug which showed up clearly with "de_DE" and we must check against it. The docs explain that, anyway:

  http://gcc.gnu.org/onlinedocs/libstdc++/install.html
Comment 6 Paolo Carlini 2008-09-29 12:48:41 UTC
*** Bug 37673 has been marked as a duplicate of this bug. ***
Comment 7 Paolo Carlini 2008-09-29 13:37:39 UTC
*** Bug 37673 has been marked as a duplicate of this bug. ***
Comment 8 Paolo Carlini 2008-09-29 14:17:36 UTC
*** Bug 37673 has been marked as a duplicate of this bug. ***