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

From: Alexander Pyhalov <alp_at_rsu.ru>
Date: Fri, 15 Aug 2014 12:31:45 +0400
Hello.
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
Received on Fri Aug 15 2014 - 06:31:49 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:51 UTC