Locale constructor locale(const locale& other, const locale& one, locale::category cats) creates named locale when 'other' - named locale, but 'one' - unnamed. According to 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. Example: [test.cpp] #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; } [tester@Fedore8 locale_name]$ g++ test.cpp && ./a.out one.name() is * other.name() is C loc.name() is C [tester@Fedore8 locale_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.
Ok.
Subject: Bug 38365 Author: paolo Date: Tue Dec 2 10:57:22 2008 New Revision: 142349 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142349 Log: 2008-12-02 Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/38365 * src/localename.cc (locale::locale(const locale&, const locale&, category)): Fix. * testsuite/22_locale/locale/cons/38365.cc: New. Added: trunk/libstdc++-v3/testsuite/22_locale/locale/cons/38365.cc Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/src/localename.cc
Fixed for 4.4.0.
According to the code, locale constructor calls void locale::_Impl::_M_replace_categories(const _Impl* __imp, category __cat) which already processes names of locales. This function works correctly, when both locales (*this and __impl) have names, or when *this locale hasn't name. But when *this locale has name, but __imp hasn't, the function doesn't clear name of *this. Your patch fixes the problem at the level of the locale constructor, but why do not fix this problem at the level of _M_replace_categories() instead?
(In reply to comment #4) > Your patch fixes the problem at the level of the locale constructor, but why do > not fix this problem at the level of _M_replace_categories() instead? Because that would not work, _M_impl has already a name ("C") by that time. Note that all these classes are suboptimal performance-wise, will be redesigned for the next ABI.
(In reply to comment #5) > (In reply to comment #4) > > Your patch fixes the problem at the level of the locale constructor, but why do > > not fix this problem at the level of _M_replace_categories() instead? > > Because that would not work, _M_impl has already a name ("C") by that time. Sorry, now I see that the involved _Impl constructor clones, thus creates an unnamed clone if the original one is unnamed, thus the idea can work.
Subject: Bug 38365 Author: paolo Date: Tue Dec 2 15:02:53 2008 New Revision: 142358 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142358 Log: 2008-12-02 Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/38365 (cont) * src/localename.cc (locale::locale(const locale&, const locale&, category)): Revert last changes. * src/localename.cc (locale::_Impl::_M_replace_categories(const _Impl*, category)): Fix here instead; rework. Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/src/localename.cc