diff --git a/libcxx/include/__functional_base b/libcxx/include/__functional_base index ef9cc03235b5..52c535aa3ea1 100644 --- a/libcxx/include/__functional_base +++ b/libcxx/include/__functional_base @@ -77,57 +77,6 @@ struct _LIBCPP_TYPE_VIS_ONLY less }; #endif -// addressof - -template -inline _LIBCPP_INLINE_VISIBILITY -_Tp* -addressof(_Tp& __x) _NOEXCEPT -{ - return (_Tp*)&reinterpret_cast(__x); -} - -#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) -// Objective-C++ Automatic Reference Counting uses qualified pointers -// that require special addressof() signatures. When -// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler -// itself is providing these definitions. Otherwise, we provide them. -template -inline _LIBCPP_INLINE_VISIBILITY -__strong _Tp* -addressof(__strong _Tp& __x) _NOEXCEPT -{ - return &__x; -} - -#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK -template -inline _LIBCPP_INLINE_VISIBILITY -__weak _Tp* -addressof(__weak _Tp& __x) _NOEXCEPT -{ - return &__x; -} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -__autoreleasing _Tp* -addressof(__autoreleasing _Tp& __x) _NOEXCEPT -{ - return &__x; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__unsafe_unretained _Tp* -addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT -{ - return &__x; -} -#endif - - // __weak_result_type template diff --git a/libcxx/include/exception b/libcxx/include/exception index 5a905e7e58d8..686e4ecd0578 100644 --- a/libcxx/include/exception +++ b/libcxx/include/exception @@ -235,7 +235,7 @@ rethrow_if_nested(const _Ep& __e, typename enable_if< is_polymorphic<_Ep>::value >::type* = 0) { - const nested_exception* __nep = dynamic_cast(&__e); + const nested_exception* __nep = dynamic_cast(_VSTD::addressof(__e)); if (__nep) __nep->rethrow_nested(); } diff --git a/libcxx/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp b/libcxx/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp index 9a44a4ec291d..a8b6e15feab8 100644 --- a/libcxx/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp +++ b/libcxx/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp @@ -37,6 +37,13 @@ public: B(const B& b) : A(b) {} }; +class C +{ +public: + virtual ~C() {} + C * operator&() const { assert(false); } // should not be called +}; + int main() { { @@ -79,7 +86,7 @@ int main() { try { - std::rethrow_if_nested(1); + std::rethrow_if_nested(C()); assert(true); } catch (...) @@ -87,4 +94,5 @@ int main() assert(false); } } + }