NetBSD-Bugs archive

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

toolchain/54411: std::locale broken

>Number:         54411
>Category:       toolchain
>Synopsis:       std::locale broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jul 27 07:05:00 +0000 2019
>Originator:     Thomas Klausner
>Release:        NetBSD 8.99.51
Curiosity is the very basis of education and if you tell me that
curiosity killed the cat, I say only that the cat died nobly.
- Arnold Edinborough
Architecture: x86_64
Machine: amd64
Using std::locale on NetBSD is completely broken with g++, and not working
correctly for at least the thousands separator for fr_FR.UTF_8 with clang++.
Save the following code to 'locale.cpp':

#include <iostream>
#include <locale>
using namespace std;

void print_thousands_separator(const char *localestring) 
    std::locale loc = std::locale(localestring);
    char thou_sep = std::use_facet<std::numpunct<wchar_t> >(loc).thousands_sep();
    cout << "Thousands separator for " << localestring << " is '" << (char)thou_sep << "'" << endl;

int main() {

and run it:

> g++ locale.cpp
> ./a.out
terminate called after throwing an instance of 'std::runtime_error'
  what():  locale::facet::_S_create_c_locale name not valid
zsh: abort (core dumped)  ./a.out

> clang++ locale.cpp
> ./a.out
Thousands separator for en_US is ','
Thousands separator for de_DE.UTF-8 is '.'
Thousands separator for fr_FR.UTF-8 is '?'

Where '?' is 0xC2; I guess it should be a space instead, but a
character > 128 looks especially wrong.
This breaks e.g. running gnucash when built with g++ if any of the
LANG or LC_* variables are set.


Home | Main Index | Thread Index | Old Index