]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR libstdc++/38365 (Locale, constructed from named and unnamed locales, become...
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 2 Dec 2008 10:57:22 +0000 (10:57 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 2 Dec 2008 10:57:22 +0000 (10:57 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/src/localename.cc
libstdc++-v3/testsuite/22_locale/locale/cons/38365.cc [new file with mode: 0644]

index ee5100f546c1e7e189b7d7896df2785efe0901f7..000430fadbe15bf76d7cf92d4768a9c6a0adcd9b 100644 (file)
@@ -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
index 5394d9a99c69f408ffef8fb0d21d003c7fa82ab3..fe6204b9b4997d208753470f5060f7a3194d4ceb 100644 (file)
@@ -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 (file)
index 0000000..1822594
--- /dev/null
@@ -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;
+}