This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[v3] Fix libstdc++/38365
- From: Paolo Carlini <paolo dot carlini at oracle dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 02 Dec 2008 11:58:13 +0100
- Subject: [v3] Fix libstdc++/38365
Hi,
tested x86_64-linux, committed to mainline.
Paolo.
////////////////
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.
Index: src/localename.cc
===================================================================
*** src/localename.cc (revision 142347)
--- src/localename.cc (working copy)
***************
*** 1,5 ****
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
! // 2006, 2007
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
--- 1,5 ----
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
! // 2006, 2007, 2008
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 157,163 ****
locale::locale(const locale& __base, const locale& __add, category __cat)
: _M_impl(0)
! { _M_coalesce(__base, __add, __cat); }
void
locale::_M_coalesce(const locale& __base, const locale& __add,
--- 157,170 ----
locale::locale(const locale& __base, const locale& __add, category __cat)
: _M_impl(0)
! {
! _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,
Index: testsuite/22_locale/locale/cons/38365.cc
===================================================================
*** testsuite/22_locale/locale/cons/38365.cc (revision 0)
--- testsuite/22_locale/locale/cons/38365.cc (revision 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;
+ }