Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2013-11-13 04:39:22 +0400
committerHoward Hinnant <hhinnant@apple.com>2013-11-13 04:39:22 +0400
commitccad8c32e08857d0a3ac6a05a1d3c69e7dd25255 (patch)
treec2ac906fe26031fd75f2866ccdd50ed9f84dfdf8 /libcxx/include/utility
parent4337e97029c18383cd34d922e9de523ad65083a6 (diff)
This fixes a very subtle ABI problem concerning the copy constructor of
pair, and a couple of pair-like implementation detail types. The C++98/03 and 11 standards all specify that the copy constructor of pair<int, int> is trivial. However as libc++ tracked the draft C++11 standard over the years, this copy constructor became non-trivial, and then just recently was corrected back to trivial for C++11. Unfortunately (for libc++1) the Itanium ABI specifies different calling conventions for trivial and non-trivial copy constructors. Therefore currently the C++03 libc++ copy constructor for pair<int, int> is ABI incompatible with the C++11 libc++ copy constructor for pair<int, int>. This is Bad(tm). This patch corrects the situation by making this copy constructor trivial in C++03 mode as well. Just in case it is needed for an incomplete C++11 compiler, libc++ retains the ability to support pair with rvalue references, but without defaulted special members. However the pair needs non-trivial special members to implement this special case, (as it did when clang was in this place a couple of years ago). During this work a bug was also found and fixed in is_trivially_constructible. And there is a minor drive-by fix in <__config> regarding __type_visibility__. A test is updated to ensure that the copy constructor of pair<int, int> is trivial in both C++03 and C++11. This test will necessarily fail for a compiler that implements rvalue references but not defaulted special members. llvm-svn: 194536
Diffstat (limited to 'libcxx/include/utility')
-rw-r--r--libcxx/include/utility2
1 files changed, 1 insertions, 1 deletions
diff --git a/libcxx/include/utility b/libcxx/include/utility
index 5fc2cf205bc2..303dd4e1508d 100644
--- a/libcxx/include/utility
+++ b/libcxx/include/utility
@@ -275,7 +275,7 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
_LIBCPP_INLINE_VISIBILITY
pair(const pair& __p) = default;
-#else
+#elif !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) // default the copy ctor in C++03
_LIBCPP_INLINE_VISIBILITY
pair(const pair& __p)
_NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&