[Bug libstdc++/85732] use_facet<moneypunct<char, true>>(mylocale) retrieving wrong locale information
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu May 10 13:08:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85732
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced:
#include <iostream>
#include <locale>
using namespace std;
void test(std::locale loc)
{
cout << "--> Setting locale '" << loc.name() << "'\n";
const moneypunct<char, true> & l_facMoneyIntl = use_facet<moneypunct<char,
true> >(loc);
const moneypunct<char, false> & l_facMoneyNatl = use_facet<moneypunct<char,
false> >(loc);
cout << "Natl Currency Symbol = '"; cout << l_facMoneyNatl.curr_symbol();
cout << "'" << "\n";
cout << "Intl Currency Symbol = '"; cout << l_facMoneyIntl.curr_symbol();
cout << "'" << "\n";
cout << "\n";
}
int main(int argc, char** argv)
{
locale global ("");
// locale::global(global);
test(locale(argc == 1 ? "pt_BR.utf8" : argv[1]));
test(global);
test(locale("C"));
}
Without -static this produces something like:
--> Setting locale 'pt_BR.utf8'
Natl Currency Symbol = 'R$'
Intl Currency Symbol = 'BRL '
--> Setting locale
'LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=en_GB.UTF-8;LC_TIME=en_GB.UTF-8;LC_COLLATE=C;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME=en_GB.UTF-8;LC_ADDRESS=en_GB.UTF-8;LC_TELEPHONE=en_GB.UTF-8;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATION=en_GB.UTF-8'
Natl Currency Symbol = '£'
Intl Currency Symbol = 'GBP '
--> Setting locale 'C'
Natl Currency Symbol = ''
Intl Currency Symbol = ''
But with -static the fields are all blank:
--> Setting locale 'pt_BR.utf8'
Natl Currency Symbol = ''
Intl Currency Symbol = ''
--> Setting locale
'LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=en_GB.UTF-8;LC_TIME=en_GB.UTF-8;LC_COLLATE=C;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME=en_GB.UTF-8;LC_ADDRESS=en_GB.UTF-8;LC_TELEPHONE=en_GB.UTF-8;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATION=en_GB.UTF-8'
Natl Currency Symbol = ''
Intl Currency Symbol = ''
--> Setting locale 'C'
Natl Currency Symbol = ''
Intl Currency Symbol = ''
I can reproduce this with any version tested (back to 4.3.6).
More information about the Gcc-bugs
mailing list