[Bug libstdc++/38368] New: locale(const char* std_name) may create locale with broken facets
tsyvarev at ispras dot ru
gcc-bugzilla@gcc.gnu.org
Tue Dec 2 09:47:00 GMT 2008
Locale constructor locale(const char* std_name) may create locale with broken
facets.
When std_name looks like "CAT1=name1;...;CATN=nameN", categories for which name
is "C" may have members, which differ from ones in "C" locale.
e.g. decimal_point() in moneypunct<> facet returns '\0' while in "C" locale it
returns '.'.
Also thousands_sep() in numpunct<> returns '\0' while in "C" locale it returns
','.
Example:
[test.cpp]
#include <locale>
#include <iostream>
using namespace std;
int main()
{
locale loc(locale("C"), "en_US", locale::collate);
cout << "Name of locale is " << loc.name() << endl;
locale loc_copy(loc.name().c_str());
if(use_facet<moneypunct<char> >(loc_copy).decimal_point() == '\0')
cout << "decimal_point() is '\\0'\n";
return 0;
}
[tester@Fedore8 locale_create_from_name]$ g++ test.cpp && ./a.out
Name of locale is
LC_CTYPE=C;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=en_US;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C
decimal_point() is '\0'
[tester@Fedore8 locale_create_from_name]$ g++ --version
g++ (GCC) 4.3.0 20080428 (Red Hat 4.3.0-8)
Copyright (C) 2008 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.
--
Summary: locale(const char* std_name) may create locale with
broken facets
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tsyvarev at ispras dot ru
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38368
More information about the Gcc-bugs
mailing list