gcc / clang std::locale issue on non-glibc platforms

Alexander Pyhalov alp at rsu.ru
Fri Aug 15 08:31:50 UTC 2014

I just stumped on the following gcc bug - 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=15992 (std::locale is not 
working for non-C locales).

It seems to affect all non-glibc platforms (reproducible on FreeBSD and 
illumos). Tried the same test with clang - no difference (as affected 
code is in libstdc++). Simple test case:

$ cat t.cpp
#include <locale>

int main (int argc, char *argv[])
     for (int i = 1; i < argc; ++i) {
         try {
             const std::locale loc (argv [i]);
         catch (std::exception &e) {
             printf ("exception: %s: %s\n", argv [i], e.what ());

$ g++ -o locale t.cpp   # or clang++ -o locale t.cpp , doesn't matter
  ./locale en_US.UTF-8
exception: en_US.UTF-8: locale::facet::_S_create_c_locale name not valid

Best regards,
Alexander Pyhalov,
system administrator of Computer Center of Southern Federal University

More information about the freebsd-current mailing list