From 94895bd98d8dc129f8a21d9a0272f5a86debcfe0 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Mon, 5 Jun 2017 17:49:04 +0100 Subject: [PATCH] PR libstdc++/80939 Remove unmeetable constexpr specifiers PR libstdc++/80939 * include/std/variant (__erased_ctor, __erased_assign, __erased_swap) (__erased_hash): Remove constexpr specifier and qualify calls to __ref_cast. (__erased_dtor): Remove constexpr specifier and use _Destroy. From-SVN: r248881 --- libstdc++-v3/ChangeLog | 8 ++++++++ libstdc++-v3/include/std/variant | 33 +++++++++++++++++++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 0b08810..9abc73c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2017-06-02 Jonathan Wakely + + PR libstdc++/80939 + * include/std/variant (__erased_ctor, __erased_assign, __erased_swap) + (__erased_hash): Remove constexpr specifier and qualify calls to + __ref_cast. + (__erased_dtor): Remove constexpr specifier and use _Destroy. + 2017-06-05 Jonathan Wakely * include/bits/stl_iterator_base_funcs.h diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index b9824a5..e5fe9f9 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -44,6 +44,9 @@ #include #include #include +#include +#include +#include namespace std _GLIBCXX_VISIBILITY(default) { @@ -238,30 +241,32 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Various functions as "vtable" entries, where those vtables are used by // polymorphic operations. template - constexpr void + void __erased_ctor(void* __lhs, void* __rhs) - { ::new (__lhs) remove_reference_t<_Lhs>(__ref_cast<_Rhs>(__rhs)); } + { + using _Type = remove_reference_t<_Lhs>; + ::new (__lhs) _Type(__variant::__ref_cast<_Rhs>(__rhs)); + } template - constexpr void + void __erased_dtor(_Variant&& __v) - { - auto&& __element = __get<_Np>(std::forward<_Variant>(__v)); - using _Type = std::remove_reference_t; - __element.~_Type(); - } + { std::_Destroy(std::__addressof(__get<_Np>(__v))); } template - constexpr void + void __erased_assign(void* __lhs, void* __rhs) - { __ref_cast<_Lhs>(__lhs) = __ref_cast<_Rhs>(__rhs); } + { + __variant::__ref_cast<_Lhs>(__lhs) = __variant::__ref_cast<_Rhs>(__rhs); + } template - constexpr void + void __erased_swap(void* __lhs, void* __rhs) { using std::swap; - swap(__ref_cast<_Lhs>(__lhs), __ref_cast<_Rhs>(__rhs)); + swap(__variant::__ref_cast<_Lhs>(__lhs), + __variant::__ref_cast<_Rhs>(__rhs)); } #define _VARIANT_RELATION_FUNCTION_TEMPLATE(__OP, __NAME) \ @@ -283,11 +288,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #undef _VARIANT_RELATION_FUNCTION_TEMPLATE template - constexpr size_t + size_t __erased_hash(void* __t) { return std::hash>>{}( - __ref_cast<_Tp>(__t)); + __variant::__ref_cast<_Tp>(__t)); } // Defines members and ctors. -- 2.7.4