Details
[Home]
Issue of the Implementation # S0743
Brief
locale(const char* std_name) may create locale with broken facets
Detailed Description
Constructor
locale(const char* std_name)
can create locale with categories from different named locales. For doing this, one can use as std_name string like
"CAT1=name1;CAT2=name2;...;CATN=nameN"
where CAT1, ..., CATN - categories (LC_TYPE, LC_COLLATE, ...), name1, ..., nameN - name of locale, from which category is taken ("C", "en_US", "ru_RU", ...).
But categories, for which name="C" in that string, may be incorrect. For example, moneypunct<char>::decimal_point() and numpunct<char<::thousands_sep() return '\0', while in "C" locale them returns '.' and ',' correspondingly.
The example below demonstrate problem with moneypunct<char>::decimal_point()(if "en_US" locale is not installed, this name may be replaced with a name of any locale installed, except "C" and "POSIX").
Problem location(s) in the standard
Linux Standard Base C++ Specification 3.2, Chapter 9. Libraries, 9.1. Interfaces for libstdcxx that refers ISO/IEC 14882: 2003 Programming languages --C++, section 22.1.1.3, p5
Example
#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; }
Component
libstdc++
Accepted
GCC Bugzilla 38368
Status
Fixed in gcc-4.4.0
[Home]