Re: g++ Locale ?? correction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2017/5/4 0:04, Papa wrote:
Yes, absolutely right. That's what I thought as well.
Now, who should look at this problem, MinGW64 or Gnu, who should I
contact to report this bug?
Please make sure it is really a bug before submitting it, by printing the first byte of the string in question in your second example, in order to make sure it is really a null-terminator (`--enable-fully-dynamic-string` may cause trouble here, see PR16612):

```c++
void jme::Locale::setGlobalLocale(const std::string& str){
      std::string tmp;
      __builtin_printf("str[0] = %d\n", str.data()[0]);
      tmp = std::setlocale(LC_ALL, str.data() );
}
```

I ask this mostly because the function `setlocale()` is provided by MSVCRT and is totally opaque to MinGW-w64. And I can't reproduce the problem:

```plaintext
E:\Desktop>cat test.cc
#include <iostream>
#include <string>
#include <clocale>

void my_set_locale_1(const std::string &str){
        auto p = std::setlocale(LC_ALL, "");
        std::cout <<__func__ <<": p = " <<p <<std::endl;
}
void my_set_locale_2(const std::string &str){
        auto p = std::setlocale(LC_ALL, str.data());
        std::cout <<__func__ <<": p = " <<p <<std::endl;
}

int main(){
        my_set_locale_1({ });
        my_set_locale_2({ });
}

E:\Desktop>g++ test.cc -Wall -Wextra -Wpedantic -std=c++11
test.cc: In function 'void my_set_locale_1(const string&)':
test.cc:5:41: warning: unused parameter 'str' [-Wunused-parameter]
 void my_set_locale_1(const std::string &str){
                                         ^~~

E:\Desktop>a.exe
my_set_locale_1: p = Chinese (Simplified)_People's Republic of China.936
my_set_locale_2: p = Chinese (Simplified)_People's Republic of China.936

E:\Desktop>
```

--
Best regards,
LH_Mouse




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux