[PATCH] D56357: Fix PR40230 - std::pair may have padding on FreeBSD.

Eric Fiselier via Phabricator reviews at reviews.llvm.org
Tue Jan 15 17:58:24 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX351290: Fix PR40230 - std::pair may have padding on FreeBSD. (authored by EricWF, committed by ).

Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56357/new/

https://reviews.llvm.org/D56357

Files:
  include/utility
  test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp
  test/libcxx/utilities/utility/pairs/pairs.pair/trivial_copy_move_ABI.pass.cpp


Index: include/utility
===================================================================
--- include/utility
+++ include/utility
@@ -303,6 +303,7 @@
 #endif
 
 #if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
+template <class, class>
 struct __non_trivially_copyable_base {
   _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
   __non_trivially_copyable_base() _NOEXCEPT {}
@@ -314,7 +315,7 @@
 template <class _T1, class _T2>
 struct _LIBCPP_TEMPLATE_VIS pair
 #if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
-: private __non_trivially_copyable_base
+: private __non_trivially_copyable_base<_T1, _T2>
 #endif
 {
     typedef _T1 first_type;
Index: test/libcxx/utilities/utility/pairs/pairs.pair/trivial_copy_move_ABI.pass.cpp
===================================================================
--- test/libcxx/utilities/utility/pairs/pairs.pair/trivial_copy_move_ABI.pass.cpp
+++ test/libcxx/utilities/utility/pairs/pairs.pair/trivial_copy_move_ABI.pass.cpp
@@ -25,6 +25,7 @@
 #include <utility>
 #include <type_traits>
 #include <cstdlib>
+#include <cstddef>
 #include <cassert>
 
 #include "test_macros.h"
@@ -81,7 +82,7 @@
 #endif
 
 
-int main()
+void test_trivial()
 {
     {
         typedef std::pair<int, short> P;
@@ -145,3 +146,15 @@
     }
 #endif
 }
+
+void test_layout() {
+    typedef std::pair<std::pair<char, char>, char> PairT;
+    static_assert(sizeof(PairT) == 3, "");
+    static_assert(TEST_ALIGNOF(PairT) == TEST_ALIGNOF(char), "");
+    static_assert(offsetof(PairT, first) == 0, "");
+}
+
+int main() {
+    test_trivial();
+    test_layout();
+}
Index: test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp
===================================================================
--- test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp
+++ test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp
@@ -30,6 +30,7 @@
 #include <utility>
 #include <type_traits>
 #include <cstdlib>
+#include <cstddef>
 #include <cassert>
 
 #include "test_macros.h"
@@ -86,7 +87,7 @@
 #endif
 
 
-int main()
+void test_trivial()
 {
     {
         typedef std::pair<int, short> P;
@@ -150,3 +151,15 @@
     }
 #endif
 }
+
+void test_layout() {
+    typedef std::pair<std::pair<char, char>, char> PairT;
+    static_assert(sizeof(PairT) == 3, "");
+    static_assert(TEST_ALIGNOF(PairT) == TEST_ALIGNOF(char), "");
+    static_assert(offsetof(PairT, first) == 0, "");
+}
+
+int main() {
+    test_trivial();
+    test_layout();
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56357.181956.patch
Type: text/x-patch
Size: 2550 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190116/e7c036e3/attachment.bin>


More information about the libcxx-commits mailing list