This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] libstdc++/14493


Hi,

this is the result of the recent discussions in mailing list and audit trail, pretty straightforward at this point. I'm going to wait a bit in case there are better options for gnu.ver: not knowing well the rationale behind the CXXABI tag, I was rather surprised to find std::bad_alloc::~bad_alloc exported as a generic library, not libsupc++ symbol (it belongs to the latter, strictly speaking). In the below I'm simply continuing the tradition, adjusting the existing exports and adding some for the what method (at 3.4.11, because we may want to commit the debug-mode thread safety fixes separately in 4_2-branch).

Tested x86-linux.

Paolo.

/////////
2007-01-31  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/14493
	* libsupc++/typeinfo (bad_cast::what, bad_typeid::what): Declare.
	* libsupc++/tinfo.cc: Define.	
	* libsupc++/exception (bad_exception::what): Declare.
	* libsupc++/eh_exception.cc: Define.
	(exception::what): Adjust, don't use typeid.
	* libsupc++/new (bad_alloc::what): Declare.
	* libsupc++/new_handler.cc: Define.
	* config/abi/pre/gnu.ver: Export the new methods @3.4.11.
	* configure.ac: Bump to 6.0.11.
	* configure: Regenerate.
	* testsuite/util/testsuite_abi.cc: Update.
	* testsuite/18_support/14493.cc: New.
Index: configure.ac
===================================================================
--- configure.ac	(revision 121300)
+++ configure.ac	(working copy)
@@ -12,7 +12,7 @@
 ### am handles this now?  ORIGINAL_LD_FOR_MULTILIBS=$LD
 
 # For libtool versioning info, format is CURRENT:REVISION:AGE
-libtool_VERSION=6:10:0
+libtool_VERSION=6:11:0
 AC_SUBST(libtool_VERSION)
 
 # Find the rest of the source tree framework.
Index: libsupc++/typeinfo
===================================================================
--- libsupc++/typeinfo	(revision 121300)
+++ libsupc++/typeinfo	(working copy)
@@ -1,5 +1,6 @@
 // RTTI support for -*- C++ -*-
-// Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002
+// Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+// 2003, 2004, 2005, 2006, 2007
 // Free Software Foundation
 //
 // This file is part of GCC.
@@ -171,6 +172,8 @@
     // This declaration is not useless:
     // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
     virtual ~bad_cast() throw();
+    // See comment in eh_exception.cc.
+    virtual const char* what() const throw();
   };
   
   /** If you use a NULL pointer in a @c typeid expression, this is thrown.  */
@@ -181,6 +184,8 @@
     // This declaration is not useless:
     // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
     virtual ~bad_typeid() throw();
+    // See comment in eh_exception.cc.
+    virtual const char* what() const throw();
   };
 } // namespace std
 
Index: libsupc++/exception
===================================================================
--- libsupc++/exception	(revision 121300)
+++ libsupc++/exception	(working copy)
@@ -1,6 +1,7 @@
 // Exception Handling support header for -*- C++ -*-
 
-// Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2005
+// Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+// 2004, 2005, 2006, 2007
 // Free Software Foundation
 //
 // This file is part of GCC.
@@ -71,6 +72,8 @@
     // This declaration is not useless:
     // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
     virtual ~bad_exception() throw();
+    // See comment in eh_exception.cc.
+    virtual const char* what() const throw();
   };
 
   /// If you write a replacement %terminate handler, it must be of this type.
Index: libsupc++/tinfo.cc
===================================================================
--- libsupc++/tinfo.cc	(revision 121300)
+++ libsupc++/tinfo.cc	(working copy)
@@ -1,5 +1,6 @@
 // Methods for type_info for -*- C++ -*- Run Time Type Identification.
-// Copyright (C) 1994, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+// Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+// 2003, 2004, 2005, 2006, 2007
 // Free Software Foundation
 //
 // This file is part of GCC.
@@ -44,6 +45,18 @@
 std::bad_cast::~bad_cast() throw() { }
 std::bad_typeid::~bad_typeid() throw() { }
 
+const char* 
+std::bad_cast::what() const throw()
+{
+  return "std::bad_cast";
+}
+
+const char* 
+std::bad_typeid::what() const throw()
+{
+  return "std::bad_typeid";
+}
+
 #if !__GXX_TYPEINFO_EQUALITY_INLINE
 
 // We can't rely on common symbols being shared between shared objects.
Index: libsupc++/new
===================================================================
--- libsupc++/new	(revision 121300)
+++ libsupc++/new	(working copy)
@@ -1,6 +1,7 @@
 // The -*- C++ -*- dynamic memory management header.
 
-// Copyright (C) 1994, 1996, 1997, 1998, 2000, 2001, 2002
+// Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+// 2003, 2004, 2005, 2006, 2007
 // Free Software Foundation
 
 // This file is part of GCC.
@@ -61,6 +62,8 @@
     // This declaration is not useless:
     // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
     virtual ~bad_alloc() throw();
+    // See comment in eh_exception.cc.
+    virtual const char* what() const throw();
   };
 
   struct nothrow_t { };
Index: libsupc++/eh_exception.cc
===================================================================
--- libsupc++/eh_exception.cc	(revision 121300)
+++ libsupc++/eh_exception.cc	(working copy)
@@ -1,5 +1,6 @@
 // -*- C++ -*- std::exception implementation.
-// Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 
+// Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+// 2003, 2004, 2005, 2006, 2007
 // Free Software Foundation
 //
 // This file is part of GCC.
@@ -39,5 +40,14 @@
 const char* 
 std::exception::what() const throw()
 {
-  return typeid (*this).name ();
+  // NB: Another elegant option would be returning typeid(*this).name()
+  // and not overriding what() in bad_exception, bad_alloc, etc.  In
+  // that case, however, mangled names would be returned, PR 14493.
+  return "std::exception";
 }
+
+const char* 
+std::bad_exception::what() const throw()
+{
+  return "std::bad_exception";
+}
Index: libsupc++/new_handler.cc
===================================================================
--- libsupc++/new_handler.cc	(revision 121300)
+++ libsupc++/new_handler.cc	(working copy)
@@ -1,6 +1,7 @@
 // Implementation file for the -*- C++ -*- dynamic memory management header.
 
-// Copyright (C) 1996, 1997, 1998, 2000, 2001, 2002
+// Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+// 2005, 2006, 2007
 // Free Software Foundation
 //
 // This file is part of GCC.
@@ -45,3 +46,9 @@
 }
 
 std::bad_alloc::~bad_alloc() throw() { }
+
+const char* 
+std::bad_alloc::what() const throw()
+{
+  return "std::bad_alloc";
+}
Index: testsuite/18_support/14493.cc
===================================================================
--- testsuite/18_support/14493.cc	(revision 0)
+++ testsuite/18_support/14493.cc	(revision 0)
@@ -0,0 +1,53 @@
+// 2007-01-30  Paolo Carlini  <pcarlini@suse.de>
+
+// Copyright (C) 2007 Free Software Foundation, Inc.
+//
+// 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.
+
+#include <new>
+#include <typeinfo>
+#include <exception>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+// libstdc++/14493
+void test01() 
+{
+  bool test __attribute__((unused)) = true;
+  using namespace std;
+
+  bad_alloc ba;
+  VERIFY( !strcmp(ba.what(), "std::bad_alloc") );
+
+  bad_cast bc;
+  VERIFY( !strcmp(bc.what(), "std::bad_cast") );
+
+  bad_typeid bt;
+  VERIFY( !strcmp(bt.what(), "std::bad_typeid") );
+
+  exception e;
+  VERIFY( !strcmp(e.what(), "std::exception") );
+
+  bad_exception be;
+  VERIFY( !strcmp(be.what(), "std::bad_exception") );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
Index: testsuite/util/testsuite_abi.cc
===================================================================
--- testsuite/util/testsuite_abi.cc	(revision 121300)
+++ testsuite/util/testsuite_abi.cc	(working copy)
@@ -1,6 +1,6 @@
 // -*- C++ -*-
 
-// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
 
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License as
@@ -189,6 +189,7 @@
       known_versions.push_back("GLIBCXX_3.4.8");
       known_versions.push_back("GLIBCXX_3.4.9");
       known_versions.push_back("GLIBCXX_3.4.10");
+      known_versions.push_back("GLIBCXX_3.4.11");
       known_versions.push_back("GLIBCXX_LDBL_3.4");
       known_versions.push_back("GLIBCXX_LDBL_3.4.7");
       known_versions.push_back("CXXABI_1.3");
Index: config/abi/pre/gnu.ver
===================================================================
--- config/abi/pre/gnu.ver	(revision 121300)
+++ config/abi/pre/gnu.ver	(working copy)
@@ -1,6 +1,7 @@
 ## Linker script for GNU versioning (GNU ld 2.13.91+ only.)
 ##
-## Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
+## Free Software Foundation, Inc.
 ##
 ## 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
@@ -26,7 +27,7 @@
     extern "C++"
     {
       std::[A-Za]*;
-      std::ba[a-r]*;
+#     std::ba[a-r]*;
       std::basic_[a-e]*;
       std::basic_f[a-r]*;
 #     std::basic_fstream;
@@ -475,6 +476,13 @@
     _ZTSN9__gnu_cxx18stdio_sync_filebufI[cw]St11char_traitsI[cw]EEE;
     _ZTSN9__gnu_cxx13stdio_filebufI[cw]St11char_traitsI[cw]EEE;
 
+    # std::bad_alloc::~bad_alloc, std::bad_cast::~bad_cast,
+    # std::bad_typeid::~bad_typeid, std::bad_exception::~bad_exception
+    _ZNSt9bad_allocD*;
+    _ZNSt8bad_castD*;
+    _ZNSt10bad_typeidD*;
+    _ZNSt13bad_exceptionD*;
+
     # function-scope static objects requires a guard variable.
     _ZGVNSt[^1]*;
     _ZGVNSt1[^7]*;
@@ -700,6 +708,15 @@
 
 } GLIBCXX_3.4.9;
 
+GLIBCXX_3.4.11 {
+
+    _ZNKSt9bad_alloc4whatEv;
+    _ZNKSt8bad_cast4whatEv;
+    _ZNKSt10bad_typeid4whatEv;
+    _ZNKSt13bad_exception4whatEv;
+
+} GLIBCXX_3.4.10;
+
 # Symbols in the support library (libsupc++) have their own tag.
 CXXABI_1.3 {
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]