C++11 const char * constructor overloads for exceptions
Ed Smith-Rowland
3dw4rd@verizon.net
Tue Oct 16 17:08:00 GMT 2012
On 10/15/2012 10:23 PM, Benjamin De Kosnik wrote:
>> This little patch adds the C++11 const char * constructor overloads
>> for exceptions.
> Seems like a good idea...
>
> but, pick one:
>
> +#ifdef __GXX_EXPERIMENTAL_CXX0X__
> + explicit logic_error(const char* __arg)
> + : logic_error(string(__arg)) { }
> +#endif
>
>
> or
>
> +
> + # const char* ctors.
> + _ZNSt11logic_errorC1EPKc;
> + _ZNSt11logic_errorC2EPKc;
>
> Ie, this should not need to be both exported and inlined.
> Might as well inline it, and not export it.
>
> -benjamin
>
I get ABI fails...
2 incompatible symbols
0
_ZNSt11logic_errorC1EPKc
std::logic_error::logic_error(char const*)
version status: incompatible
GLIBCXX_3.4
type: function
status: added
1
_ZNSt11logic_errorC2EPKc
std::logic_error::logic_error(char const*)
version status: incompatible
GLIBCXX_3.4
type: function
status: added
==== libstdc++-v3 check-abi Summary ====
# of added symbols: 32
# of missing symbols: 0
# of undesignated symbols: 0
# of incompatible symbols: 2
using: baseline_symbols.txt
FAIL: libstdc++-abi/abi_check
testcase /home/ed/gcc_tr2/libstdc++-v3/testsuite/libstdc++-abi/abi.exp
completed in 10 seconds
Running
/home/ed/gcc_tr2/libstdc++-v3/testsuite/libstdc++-dg/conformance.exp ...
I guess this gets outlined for some reason. Is there a better fix for this?
I guess I could just add the two symbols?
Ed
-------------- next part --------------
2012-10-16 Edward Smith-Rowland <3dw4rd@verizon.net>
* include/std/system_error (system_error(error_code, const char*),
system_error(int, const error_category&, const char*)): New.
* include/std/stdexcept ( logic_error(const char*),
domain_error(const char*), invalid_argument(const char*),
length_error(const char*), out_of_range(const char*),
runtime_error(const char*), range_error(const char*),
overflow_error(const char*), underflow_error(const char*)): New.
* config/abi/pre/gnu.ver: Add symbols for logic_error const char* ctors.
-------------- next part --------------
Index: include/std/system_error
===================================================================
--- include/std/system_error (revision 192504)
+++ include/std/system_error (working copy)
@@ -1,6 +1,7 @@
// <system_error> -*- C++ -*-
-// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2007-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
@@ -318,17 +319,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 192504)
+++ include/std/stdexcept (working copy)
@@ -1,6 +1,6 @@
// Standard exception classes -*- C++ -*-
-// Copyright (C) 2001, 2002, 2005, 2007, 2009, 2010, 2011
+// Copyright (C) 2001, 2002, 2005, 2007, 2009-2012
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -59,8 +59,11 @@
public:
/** Takes a character string describing the error. */
- explicit
- logic_error(const string& __arg);
+ explicit logic_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit logic_error(const char* __arg)
+ : logic_error(string(__arg)) { }
+#endif
virtual ~logic_error() _GLIBCXX_USE_NOEXCEPT;
@@ -76,6 +79,10 @@
{
public:
explicit domain_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit domain_error(const char* __arg)
+ : domain_error(string(__arg)) { }
+#endif
virtual ~domain_error() _GLIBCXX_USE_NOEXCEPT;
};
@@ -84,6 +91,10 @@
{
public:
explicit invalid_argument(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit invalid_argument(const char* __arg)
+ : invalid_argument(string(__arg)) { }
+#endif
virtual ~invalid_argument() _GLIBCXX_USE_NOEXCEPT;
};
@@ -93,6 +104,10 @@
{
public:
explicit length_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit length_error(const char* __arg)
+ : length_error(string(__arg)) { }
+#endif
virtual ~length_error() _GLIBCXX_USE_NOEXCEPT;
};
@@ -102,6 +117,10 @@
{
public:
explicit out_of_range(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit out_of_range(const char* __arg)
+ : out_of_range(string(__arg)) { }
+#endif
virtual ~out_of_range() _GLIBCXX_USE_NOEXCEPT;
};
@@ -116,8 +135,11 @@
public:
/** Takes a character string describing the error. */
- explicit
- runtime_error(const string& __arg);
+ explicit runtime_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit runtime_error(const char* __arg)
+ : runtime_error(string(__arg)) { }
+#endif
virtual ~runtime_error() _GLIBCXX_USE_NOEXCEPT;
@@ -132,6 +154,10 @@
{
public:
explicit range_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit range_error(const char* __arg)
+ : range_error(string(__arg)) { }
+#endif
virtual ~range_error() _GLIBCXX_USE_NOEXCEPT;
};
@@ -140,6 +166,10 @@
{
public:
explicit overflow_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit overflow_error(const char* __arg)
+ : overflow_error(string(__arg)) { }
+#endif
virtual ~overflow_error() _GLIBCXX_USE_NOEXCEPT;
};
@@ -148,6 +178,10 @@
{
public:
explicit underflow_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit underflow_error(const char* __arg)
+ : underflow_error(string(__arg)) { }
+#endif
virtual ~underflow_error() _GLIBCXX_USE_NOEXCEPT;
};
Index: config/abi/pre/gnu.ver
===================================================================
--- config/abi/pre/gnu.ver (revision 192504)
+++ config/abi/pre/gnu.ver (working copy)
@@ -1339,6 +1339,10 @@
# construction vtable
_ZTCSt*;
+ # const char* ctors for logic_error.
+ _ZNSt11logic_errorC1EPKc;
+ _ZNSt11logic_errorC2EPKc;
+
} GLIBCXX_3.4.17;
# Symbols in the support library (libsupc++) have their own tag.
More information about the Libstdc++
mailing list