Issue of the Implementation # S0743


locale(const char* std_name) may create locale with broken facets

Detailed Description


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


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, p5


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

int main()
    locale loc(locale("C"), "en_US", locale::collate);
    cout << "Name of locale is " << << endl;
    locale loc_copy(;
    if(use_facet<moneypunct<char> >(loc_copy).decimal_point() == '\0')
        cout << "decimal_point() is '\\0'\n";
    return 0;




GCC Bugzilla 38368


Fixed in gcc-4.4.0