re PR libstdc++/14493 (std::bad_alloc::what() does not explain what happened)

2007-02-01  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.9; adjust
	existing 3.4.10 exports to 3.4.9.
	* configure.ac: Adjust to 6.0.9.
	* configure: Regenerate.
	* testsuite/util/testsuite_abi.cc: Update.
	* testsuite/18_support/14493.cc: New.

From-SVN: r121461
This commit is contained in:
Paolo Carlini 2007-02-01 13:36:51 +00:00 committed by Paolo Carlini
parent ee7d8048d5
commit c3f0f556db
12 changed files with 137 additions and 18 deletions

View File

@ -1,3 +1,20 @@
2007-02-01 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.9; adjust
existing 3.4.10 exports to 3.4.9.
* configure.ac: Adjust to 6.0.9.
* configure: Regenerate.
* testsuite/util/testsuite_abi.cc: Update.
* testsuite/18_support/14493.cc: New.
2007-02-01 Ben Elliston <bje@au.ibm.com>
* libsupc++/eh_alloc.cc (__cxa_free_exception): Don't refer to the

View File

@ -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 @@ GLIBCXX_3.4 {
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 @@ GLIBCXX_3.4 {
_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]*;
@ -689,16 +697,17 @@ GLIBCXX_3.4.9 {
_ZNSo9_M_insertEPKc[il];
_ZNSt13basic_ostreamIwSt11char_traitsIwEE9_M_insertEPKw[il];
} GLIBCXX_3.4.8;
GLIBCXX_3.4.10 {
_ZN11__gnu_debug19_Safe_sequence_base12_M_get_mutexEv;
_ZN11__gnu_debug19_Safe_iterator_base16_M_attach_singleEPNS_19_Safe_sequence_baseEb;
_ZN11__gnu_debug19_Safe_iterator_base16_M_detach_singleEv;
_ZN11__gnu_debug19_Safe_iterator_base12_M_get_mutexEv;
} GLIBCXX_3.4.9;
_ZNKSt9bad_alloc4whatEv;
_ZNKSt8bad_cast4whatEv;
_ZNKSt10bad_typeid4whatEv;
_ZNKSt13bad_exception4whatEv;
} GLIBCXX_3.4.8;
# Symbols in the support library (libsupc++) have their own tag.
CXXABI_1.3 {

View File

@ -1381,7 +1381,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
### 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:9:0
# Find the rest of the source tree framework.

View File

@ -12,7 +12,7 @@ AC_CONFIG_HEADER(config.h)
### 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:9:0
AC_SUBST(libtool_VERSION)
# Find the rest of the source tree framework.

View File

@ -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 @@ std::bad_exception::~bad_exception() throw() { }
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";
}

View File

@ -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 @@ namespace std
// 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.

View File

@ -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 @@ namespace std
// 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 { };

View File

@ -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::set_new_handler (new_handler handler) throw()
}
std::bad_alloc::~bad_alloc() throw() { }
const char*
std::bad_alloc::what() const throw()
{
return "std::bad_alloc";
}

View File

@ -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::type_info::
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.

View File

@ -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 @@ namespace std
// 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 @@ namespace std
// 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

View File

@ -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;
}

View File

@ -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
@ -188,7 +188,6 @@ check_version(symbol& test, bool added)
known_versions.push_back("GLIBCXX_3.4.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_LDBL_3.4");
known_versions.push_back("GLIBCXX_LDBL_3.4.7");
known_versions.push_back("CXXABI_1.3");