diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2008-12-02 10:57:22 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2008-12-02 10:57:22 +0000 |
commit | 95e5f0ce004baee612104311868171e748dfc43c (patch) | |
tree | 7bd7887cae9262cf9903166849de818a0cc43383 /libstdc++-v3 | |
parent | 0d2a6e08da09208f8c93b36cf8a2a216b1db1955 (diff) | |
download | gcc-95e5f0ce004baee612104311868171e748dfc43c.zip gcc-95e5f0ce004baee612104311868171e748dfc43c.tar.gz gcc-95e5f0ce004baee612104311868171e748dfc43c.tar.bz2 |
re PR libstdc++/38365 (Locale, constructed from named and unnamed locales, become named)
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.
From-SVN: r142349
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 7 | ||||
-rw-r--r-- | libstdc++-v3/src/localename.cc | 11 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/22_locale/locale/cons/38365.cc | 45 |
3 files changed, 61 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index ee5100f..000430f 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +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. + 2008-12-01 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/38080 diff --git a/libstdc++-v3/src/localename.cc b/libstdc++-v3/src/localename.cc index 5394d9a..fe6204b 100644 --- a/libstdc++-v3/src/localename.cc +++ b/libstdc++-v3/src/localename.cc @@ -1,5 +1,5 @@ // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, -// 2006, 2007 +// 2006, 2007, 2008 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -157,7 +157,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std) locale::locale(const locale& __base, const locale& __add, category __cat) : _M_impl(0) - { _M_coalesce(__base, __add, __cat); } + { + _M_coalesce(__base, __add, __cat); + if (!__base._M_impl->_M_names[0] || !__add._M_impl->_M_names[0]) + { + delete [] _M_impl->_M_names[0]; + _M_impl->_M_names[0] = 0; // Unnamed. + } + } void locale::_M_coalesce(const locale& __base, const locale& __add, diff --git a/libstdc++-v3/testsuite/22_locale/locale/cons/38365.cc b/libstdc++-v3/testsuite/22_locale/locale/cons/38365.cc new file mode 100644 index 0000000..1822594 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/locale/cons/38365.cc @@ -0,0 +1,45 @@ +// { dg-require-namedlocale "" } + +// Copyright (C) 2008 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 22.1.1.2 locale constructors and destructors [lib.locale.cons] + +#include <locale> +#include <testsuite_hooks.h> + +// libstdc++/38365 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + locale other(locale("C")); + locale one(locale("en_US"), new ctype<char>()); + locale loc(other, one, locale::collate); + + VERIFY( one.name() == "*" ); + VERIFY( other.name() == "C" ); + VERIFY( loc.name() == "*" ); +} + +int main() +{ + test01(); + return 0; +} |