g++ Locale ?? correction

Liu Hao lh_mouse@126.com
Wed May 3 07:17:00 GMT 2017


On 2017/5/3 15:09, Xi Ruoyao wrote:
> On 2017-05-03 14:32 +0800, Liu Hao wrote:
>> On 2017/5/3 14:12, Xi Ruoyao wrote:
>>> Liu Hao (CCed him) once said his (maybe modified) libstdc++
>>> also support locale name "" (empty string).  Maybe he can help
>>> you.
>> No I didn't modify GCC or libstdc++ source. The "" (empty string) locale
>> works fine and conforms to the standard on my computer (that is, it is
>> identical to the "C" locale).
>
> So where did you get the code?  Libstdc++ in current GCC trunk throw
> exception for all locales (even if "") except "C".
>
> I'll look at the standard.  Maybe upstream libstdc++ need a fix for
> "" locale.
>

```plaintext
E:\Desktop>g++ --version
g++ (gcc-7-branch HEAD with MCF thread model, built by LH_Mouse.) 7.1.1 
20170503
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


E:\Desktop>cat test.cc
#include <locale>
#include <iostream>

int main()
{
   std::locale::global(std::locale(""));

   std::locale current_locale;
   std::cout << "Locale is now: " << current_locale.name() << std::endl;
   return 0;
}

E:\Desktop>g++ test.cc -std=c++11 -Wall -Wextra -pedantic

E:\Desktop>a.exe
Locale is now: C
```

No errors. No exceptions.

-- 
Best regards,
LH_Mouse



More information about the Gcc-help mailing list