This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Dup status.

378. locale immutability and locale::operator=()

Section: 26.3.1 [locale] Status: Dup Submitter: Martin Sebor Opened: 2002-09-06 Last modified: 2016-02-10

Priority: Not Prioritized

View all other issues in [locale].

View all issues with Dup status.

Duplicate of: 31


I think there is a problem with 22.1.1, p6 which says that

    -6- An instance of locale is immutable; once a facet reference
        is obtained from it, that reference remains usable as long
        as the locale value itself exists.

and, p4:

    const locale& operator=(const locale& other) throw();

    -4- Effects: Creates a copy of other, replacing the current value.

How can a reference to a facet obtained from a locale object remain valid after an assignment that clearly must replace all the facets in the locale object? Imagine a program such as this

    std::locale loc ("de_DE");
    const std::ctype<char> &r0 = std::use_facet<std::ctype<char> >(loc);
    loc = std::locale ("en_US");
    const std::ctype<char> &r1 = std::use_facet<std::ctype<char> >(loc);

Is r0 really supposed to be preserved and destroyed only when loc goes out of scope?

Proposed resolution:

[Summer '04 mid-meeting mailing: Martin and Dietmar believe this is a duplicate of issue 31 and recommend that it be closed. ]