Details

[Home]

Issue of the Implementation # S0745

Brief

Locale, constructed from named and unnamed locales, become named

Detailed Description

Common locale description says (22.1.1 p8):

A locale constructed from a name string (such as "POSIX"), or from parts of two named locales, has a name; all others do not. Named locales may be compared for equality; an unnamed locale is equal only to (copies of) itself. For an unnamed locale, locale::name() returns the string “*”.


But constructor

locale(const locale& other, const locale& one, locale::category cats)

creates locale, for which name() returns not "*", in case when
other - named locale (other.name() returns not "*"), but
one - unnamed locale (one.name() returns "*").

The example below demonstrated such behaviour of the function.

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

Example

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

int main()
{
    locale other(locale("C"));
    locale one(locale("en_US"), new ctype<char>());
    locale loc(other, one, locale::collate);
    cout << "one.name() is " << one.name() << endl;
    cout << "other.name() is " << other.name() << endl;
    cout << "loc.name() is " << loc.name() << endl;
    return 0;
}

Component

libstdc++

Accepted

GCC Bugzilla 38365

Status

Fixed in gcc-4.4.0

[Home]