From b7361983d180fd14bd070c70542d30d631488ea0 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Mon, 16 Mar 2015 15:10:28 +0000 Subject: [PATCH] Fix a problem when calling throw_with_nested with a class marked 'final'. Thanks to STL @ Microsoft for the bug report. llvm-svn: 232384 --- libcxx/include/exception | 6 ++++++ .../except.nested/throw_with_nested.pass.cpp | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/libcxx/include/exception b/libcxx/include/exception index cad802e..2d8c0f5 100644 --- a/libcxx/include/exception +++ b/libcxx/include/exception @@ -193,6 +193,9 @@ void throw_with_nested(_Tp&& __t, typename enable_if< is_class::type>::value && !is_base_of::type>::value +#if _LIBCPP_STD_VER > 11 + && !is_final::type>::value +#endif >::type* = 0) #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES throw_with_nested (_Tp& __t, typename enable_if< @@ -212,6 +215,9 @@ void throw_with_nested(_Tp&& __t, typename enable_if< !is_class::type>::value || is_base_of::type>::value +#if _LIBCPP_STD_VER > 11 + || is_final::type>::value +#endif >::type* = 0) #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES throw_with_nested (_Tp& __t, typename enable_if< diff --git a/libcxx/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp b/libcxx/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp index 887264a..dad0df2 100644 --- a/libcxx/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp +++ b/libcxx/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp @@ -36,6 +36,10 @@ public: friend bool operator==(const B& x, const B& y) {return x.data_ == y.data_;} }; +#if __cplusplus > 201103L +struct Final final {}; +#endif + int main() { { @@ -100,4 +104,16 @@ int main() assert(i == 7); } } +#if __cplusplus > 201103L + { + try + { + std::throw_with_nested(Final()); + assert(false); + } + catch (const Final &f) + { + } + } +#endif } -- 2.7.4