g++ Locale ?? correction

Papa papa@arbolone.ca
Wed May 3 14:00:00 GMT 2017


Thanks for the comments, however, as long as gcc does not provide a 
solid support for std::locale, I would say it is better to use 
std::setlocale(...). So, in that regard, I'd like to provide another 
piece of information that I consider extremely interesting, since it 
appears to be a bug and not a human error, please look at the following code

<snip>
//This code works ??
void jme::Locale::setGlobalLocale(const std::string& str){
      std::string tmp;
      tmp = std::setlocale(LC_ALL, "");
}
</snip>

<snip>
//This does not code works ??
void jme::Locale::setGlobalLocale(const std::string& str){
      std::string tmp;
      tmp = std::setlocale(LC_ALL, str.data() );
}
</snip>

This shows that either std::setlocale(...)  does not know how to handle 
std::string::data()/std::string::c_str()  return value or neither 
std::string::data() nor std::string::c_str() return the expected value

I am using Win8.1 and COLLECT_GCC=C:\gnu\mingw-w64\mingw64\bin\g++.exe
COLLECT_LTO_WRAPPER=C:/gnu/mingw-w64/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/6.3.0/lto-wrapper.exe

I wonder if I should change to TDM, but I don't see how it would benefit 
to the solution of this problem.

Thanks all for the help.

Target: x86_64-w64-mingw32
On 03-May-2017 3:22 AM, Liu Hao wrote:
> On 2017/5/3 15:09, Xi Ruoyao wrote:
>> So where did you get the code?  Libstdc++ in current GCC trunk throw
>> exception for all locales (even if "") except "C".
>>
> See 
> <https://github.com/lhmouse/MINGW-packages/tree/master/mingw-w64-gcc-git> 
> for patches and build scripts, most of which are merely forked from 
> MSYS2.
>
>> I'll look at the standard.  Maybe upstream libstdc++ need a fix for
>> "" locale.
>>
> See N4618 [locale.cons]/6:
>
> ```plaintext
> explicit locale(const char* std_name);
> 6 Remarks: The set of valid string argument values is "C", "", and any 
> implementation-defined values.
> ```
>

-- 
ArbolOne.ca
Using FireFox and Thunderbird.
ArbolOne is composed of a group of students and volunteers
dedicated to providing free services to charitable organizations.

-------------- next part --------------
g++ : Using built-in specs.
At line:1 char:1
+ g++ -v 2> c:\Temp\g++Version.txt
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Using built-in specs.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
COLLECT_GCC=C:\gnu\mingw-w64\mingw64\bin\g++.exe
COLLECT_LTO_WRAPPER=C:/gnu/mingw-w64/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/6.3.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-6.3.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 
--target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw630/x86_64-630-posix-seh-rt_v5-rev2/mingw64 
--enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes 
--enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release 
--enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-libstdcxx-filesystem-ts=yes 
--disable-libstdcxx-pch --disable-libstdcxx-debug --disable-bootstrap --disable-rpath --disable-win32-registry 
--disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 
--with-libiconv --with-system-zlib --with-gmp=/c/mingw630/prerequisites/x86_64-w64-mingw32-static 
--with-mpfr=/c/mingw630/prerequisites/x86_64-w64-mingw32-static 
--with-mpc=/c/mingw630/prerequisites/x86_64-w64-mingw32-static 
--with-isl=/c/mingw630/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-seh-rev2, Built by 
MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident 
-I/c/mingw630/x86_64-630-posix-seh-rt_v5-rev2/mingw64/opt/include 
-I/c/mingw630/prerequisites/x86_64-zlib-static/include -I/c/mingw630/prerequisites/x86_64-w64-mingw32-static/include' 
CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw630/x86_64-630-posix-seh-rt_v5-rev2/mingw64/opt/include 
-I/c/mingw630/prerequisites/x86_64-zlib-static/include -I/c/mingw630/prerequisites/x86_64-w64-mingw32-static/include' 
CPPFLAGS=' -I/c/mingw630/x86_64-630-posix-seh-rt_v5-rev2/mingw64/opt/include 
-I/c/mingw630/prerequisites/x86_64-zlib-static/include -I/c/mingw630/prerequisites/x86_64-w64-mingw32-static/include' 
LDFLAGS='-pipe -fno-ident -L/c/mingw630/x86_64-630-posix-seh-rt_v5-rev2/mingw64/opt/lib 
-L/c/mingw630/prerequisites/x86_64-zlib-static/lib -L/c/mingw630/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: posix
gcc version 6.3.0 (x86_64-posix-seh-rev2, Built by MinGW-W64 project) 



More information about the Gcc-help mailing list