const char* constructor overloads for stdexcept and system_error.
Ed Smith-Rowland
3dw4rd@verizon.net
Sun Jun 24 03:58:00 GMT 2012
Here is a beginning patch to add const char* constructors for the
standard exception classes.
I didn't bump the so version because I'm not positive how to do it. I
tried changing libtool_VERSION in acinclude.m4 and running the autotools
commands. The diffs were very messy because my machine has autotools
1.11.3 rather than 1.11.1. Also, we might want to wait for something
cooler to bump the soname.
Ed
-------------- next part --------------
Index: include/std/system_error
===================================================================
--- include/std/system_error (revision 188848)
+++ include/std/system_error (working copy)
@@ -318,17 +318,13 @@
system_error(error_code __ec, const string& __what)
: runtime_error(__what + ": " + __ec.message()), _M_code(__ec) { }
- /*
- * TODO: Add const char* ctors to all exceptions.
- *
- * system_error(error_code __ec, const char* __what)
- * : runtime_error(__what + (": " + __ec.message())), _M_code(__ec) { }
- *
- * system_error(int __v, const error_category& __ecat, const char* __what)
- * : runtime_error(__what + (": " + __ec.message())),
- * _M_code(error_code(__v, __ecat)) { }
- */
+ system_error(error_code __ec, const char* __what)
+ : runtime_error(__what + (": " + __ec.message())), _M_code(__ec) { }
+ system_error(int __v, const error_category& __ecat, const char* __what)
+ : runtime_error(__what + (": " + error_code(__v, __ecat).message())),
+ _M_code(__v, __ecat) { }
+
system_error(int __v, const error_category& __ecat)
: runtime_error(error_code(__v, __ecat).message()),
_M_code(__v, __ecat) { }
Index: include/std/stdexcept
===================================================================
--- include/std/stdexcept (revision 188848)
+++ include/std/stdexcept (working copy)
@@ -61,6 +61,10 @@
/** Takes a character string describing the error. */
explicit
logic_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit
+ logic_error(const char* __arg);
+#endif
virtual ~logic_error() _GLIBCXX_USE_NOEXCEPT;
@@ -76,6 +80,9 @@
{
public:
explicit domain_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit domain_error(const char* __arg);
+#endif
virtual ~domain_error() _GLIBCXX_USE_NOEXCEPT;
};
@@ -84,6 +91,9 @@
{
public:
explicit invalid_argument(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit invalid_argument(const char* __arg);
+#endif
virtual ~invalid_argument() _GLIBCXX_USE_NOEXCEPT;
};
@@ -93,6 +103,9 @@
{
public:
explicit length_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit length_error(const char* __arg);
+#endif
virtual ~length_error() _GLIBCXX_USE_NOEXCEPT;
};
@@ -102,6 +115,9 @@
{
public:
explicit out_of_range(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit out_of_range(const char* __arg);
+#endif
virtual ~out_of_range() _GLIBCXX_USE_NOEXCEPT;
};
@@ -118,6 +134,10 @@
/** Takes a character string describing the error. */
explicit
runtime_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit
+ runtime_error(const char* __arg);
+#endif
virtual ~runtime_error() _GLIBCXX_USE_NOEXCEPT;
@@ -132,6 +152,9 @@
{
public:
explicit range_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit range_error(const char* __arg);
+#endif
virtual ~range_error() _GLIBCXX_USE_NOEXCEPT;
};
@@ -140,6 +163,9 @@
{
public:
explicit overflow_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit overflow_error(const char* __arg);
+#endif
virtual ~overflow_error() _GLIBCXX_USE_NOEXCEPT;
};
@@ -148,6 +174,9 @@
{
public:
explicit underflow_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit underflow_error(const char* __arg);
+#endif
virtual ~underflow_error() _GLIBCXX_USE_NOEXCEPT;
};
Index: testsuite/util/testsuite_abi.cc
===================================================================
--- testsuite/util/testsuite_abi.cc (revision 188848)
+++ testsuite/util/testsuite_abi.cc (working copy)
@@ -195,6 +195,7 @@
known_versions.push_back("GLIBCXX_3.4.15");
known_versions.push_back("GLIBCXX_3.4.16");
known_versions.push_back("GLIBCXX_3.4.17");
+ known_versions.push_back("GLIBCXX_3.4.18");
known_versions.push_back("GLIBCXX_LDBL_3.4");
known_versions.push_back("GLIBCXX_LDBL_3.4.7");
known_versions.push_back("GLIBCXX_LDBL_3.4.10");
Index: src/c++11/Makefile.in
===================================================================
--- src/c++11/Makefile.in (revision 188848)
+++ src/c++11/Makefile.in (working copy)
@@ -69,7 +69,7 @@
am__objects_1 = chrono.lo condition_variable.lo debug.lo \
functexcept.lo functional.lo future.lo hash_c++0x.lo \
hashtable_c++0x.lo limits.lo mutex.lo placeholders.lo regex.lo \
- shared_ptr.lo system_error.lo thread.lo
+ shared_ptr.lo stdexcept-c++11.lo system_error.lo thread.lo
@ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_2 = fstream-inst.lo \
@ENABLE_EXTERN_TEMPLATE_TRUE@ string-inst.lo wstring-inst.lo
am_libc__11convenience_la_OBJECTS = $(am__objects_1) $(am__objects_2)
@@ -311,6 +311,7 @@
placeholders.cc \
regex.cc \
shared_ptr.cc \
+ stdexcept-c++11.cc \
system_error.cc \
thread.cc
Index: src/c++11/stdexcept-c++11.cc
===================================================================
--- src/c++11/stdexcept-c++11.cc (revision 0)
+++ src/c++11/stdexcept-c++11.cc (revision 0)
@@ -0,0 +1,65 @@
+// Methods for Exception Support for -*- C++ -*-
+
+// Copyright (C) 2012
+// 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 3, 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.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+//
+// ISO C++ 14882: 19.1 Exception classes
+//
+
+#include <string>
+#include <stdexcept>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ logic_error::logic_error(const char* __arg)
+ : logic_error(string(__arg)) { }
+
+ domain_error::domain_error(const char* __arg)
+ : domain_error(string(__arg)) { }
+
+ invalid_argument::invalid_argument(const char* __arg)
+ : invalid_argument(string(__arg)) { }
+
+ length_error::length_error(const char* __arg)
+ : length_error(string(__arg)) { }
+
+ out_of_range::out_of_range(const char* __arg)
+ : out_of_range(string(__arg)) { }
+
+ runtime_error::runtime_error(const char* __arg)
+ : runtime_error(string(__arg)) { }
+
+ range_error::range_error(const char* __arg)
+ : range_error(string(__arg)) { }
+
+ overflow_error::overflow_error(const char* __arg)
+ : overflow_error(string(__arg)) { }
+
+ underflow_error::underflow_error(const char* __arg)
+ : underflow_error(string(__arg)) { }
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
Index: src/c++11/Makefile.am
===================================================================
--- src/c++11/Makefile.am (revision 188848)
+++ src/c++11/Makefile.am (working copy)
@@ -43,6 +43,7 @@
placeholders.cc \
regex.cc \
shared_ptr.cc \
+ stdexcept-c++11.cc \
system_error.cc \
thread.cc
Index: config/abi/pre/gnu.ver
===================================================================
--- config/abi/pre/gnu.ver (revision 188848)
+++ config/abi/pre/gnu.ver (working copy)
@@ -1321,6 +1321,23 @@
} GLIBCXX_3.4.16;
+GLIBCXX_3.4.18 {
+
+ # const char* ctors for stdexcept.
+ _ZNSt11logic_errorC1EPKc;
+ _ZNSt11range_errorC1EPKc;
+ _ZNSt12domain_errorC1EPKc;
+ _ZNSt12length_errorC1EPKc;
+ _ZNSt12out_of_rangeC1EPKc;
+ _ZNSt13runtime_errorC1EPKc;
+ _ZNSt14overflow_errorC1EPKc;
+ _ZNSt15underflow_errorC1EPKc;
+ _ZNSt16invalid_argumentC1EPKc;
+ _ZNSt12system_errorD1Ev;
+ _ZTVSt12system_error;
+
+} GLIBCXX_3.4.17;
+
# Symbols in the support library (libsupc++) have their own tag.
CXXABI_1.3 {
@@ -1522,4 +1539,4 @@
global:
__cxa_tm_cleanup;
-};
\ No newline at end of file
+};
More information about the Libstdc++
mailing list