[libcxx] r294133 - Change the base class of std::bad_optional_access. This is a (subtle) ABI change, and is in response to http://http://wg21.link/LWG2806, which I *expect* to be adopted in Kona. I am making this change now in anticipation, and will get it into 4.0, because (a) 4.0 is the first release with std::optional, and (b) I don't want to make an ABI-change later, when the user base should be significantly larger. Note that I didn't change std::experimental::bad_optional_access, because that's sti...
Marshall Clow via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 5 12:06:39 PST 2017
Author: marshall
Date: Sun Feb 5 14:06:38 2017
New Revision: 294133
URL: http://llvm.org/viewvc/llvm-project?rev=294133&view=rev
Log:
Change the base class of std::bad_optional_access. This is a (subtle) ABI change, and is in response to http://http://wg21.link/LWG2806, which I *expect* to be adopted in Kona. I am making this change now in anticipation, and will get it into 4.0, because (a) 4.0 is the first release with std::optional, and (b) I don't want to make an ABI-change later, when the user base should be significantly larger. Note that I didn't change std::experimental::bad_optional_access, because that's still specified to derive from std::logic_error.
Modified:
libcxx/trunk/include/experimental/optional
libcxx/trunk/include/optional
libcxx/trunk/src/optional.cpp
libcxx/trunk/test/std/utilities/optional/optional.bad_optional_access/derive.pass.cpp
Modified: libcxx/trunk/include/experimental/optional
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/optional?rev=294133&r1=294132&r2=294133&view=diff
==============================================================================
--- libcxx/trunk/include/experimental/optional (original)
+++ libcxx/trunk/include/experimental/optional Sun Feb 5 14:06:38 2017
@@ -152,7 +152,7 @@ public:
bad_optional_access() : std::logic_error("Bad optional Access") {}
// Get the key function ~bad_optional_access() into the dylib
- virtual ~bad_optional_access() _NOEXCEPT;
+ virtual ~bad_optional_access();
};
_LIBCPP_END_NAMESPACE_EXPERIMENTAL
Modified: libcxx/trunk/include/optional
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/optional?rev=294133&r1=294132&r2=294133&view=diff
==============================================================================
--- libcxx/trunk/include/optional (original)
+++ libcxx/trunk/include/optional Sun Feb 5 14:06:38 2017
@@ -160,14 +160,12 @@ namespace std // purposefully not using
{
class _LIBCPP_EXCEPTION_ABI bad_optional_access
- : public logic_error
+ : public exception
{
public:
- _LIBCPP_INLINE_VISIBILITY
- bad_optional_access() : logic_error("bad optional access") {}
-
// Get the key function ~bad_optional_access() into the dylib
- virtual ~bad_optional_access() _NOEXCEPT;
+ virtual ~bad_optional_access();
+ virtual const char* what() const _NOEXCEPT;
};
} // std
Modified: libcxx/trunk/src/optional.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/optional.cpp?rev=294133&r1=294132&r2=294133&view=diff
==============================================================================
--- libcxx/trunk/src/optional.cpp (original)
+++ libcxx/trunk/src/optional.cpp Sun Feb 5 14:06:38 2017
@@ -13,12 +13,16 @@
namespace std
{
-bad_optional_access::~bad_optional_access() _NOEXCEPT = default;
+bad_optional_access::~bad_optional_access() = default;
+
+const char* bad_optional_access::what() const _NOEXCEPT {
+ return "bad_optional_access";
+ }
} // std
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
-bad_optional_access::~bad_optional_access() _NOEXCEPT = default;
+bad_optional_access::~bad_optional_access() = default;
_LIBCPP_END_NAMESPACE_EXPERIMENTAL
Modified: libcxx/trunk/test/std/utilities/optional/optional.bad_optional_access/derive.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.bad_optional_access/derive.pass.cpp?rev=294133&r1=294132&r2=294133&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/optional/optional.bad_optional_access/derive.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/optional/optional.bad_optional_access/derive.pass.cpp Sun Feb 5 14:06:38 2017
@@ -11,7 +11,7 @@
// <optional>
-// class bad_optional_access : public logic_error
+// class bad_optional_access : public exception
#include <optional>
#include <type_traits>
@@ -20,6 +20,6 @@ int main()
{
using std::bad_optional_access;
- static_assert(std::is_base_of<std::logic_error, bad_optional_access>::value, "");
- static_assert(std::is_convertible<bad_optional_access*, std::logic_error*>::value, "");
+ static_assert(std::is_base_of<std::exception, bad_optional_access>::value, "");
+ static_assert(std::is_convertible<bad_optional_access*, std::exception*>::value, "");
}
More information about the cfe-commits
mailing list