From ebff3123a2d7c6b3d74d27c50700f0582ec45e85 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Wed, 12 Sep 2018 14:46:17 +0000 Subject: [PATCH] Implement LWG #3017. list splice functions should use addressof llvm-svn: 342057 --- libcxx/include/list | 2 +- .../std/containers/sequences/list/list.ops/merge.pass.cpp | 11 +++++++++++ .../containers/sequences/list/list.ops/merge_comp.pass.cpp | 10 ++++++++++ libcxx/www/cxx2a_status.html | 10 +++++----- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/libcxx/include/list b/libcxx/include/list index d2e78cd..49e2e1e 100644 --- a/libcxx/include/list +++ b/libcxx/include/list @@ -2208,7 +2208,7 @@ template void list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) { - if (this != &__c) + if (this != _VSTD::addressof(__c)) { iterator __f1 = begin(); iterator __e1 = end(); diff --git a/libcxx/test/std/containers/sequences/list/list.ops/merge.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/merge.pass.cpp index 7c12877..af4b02c 100644 --- a/libcxx/test/std/containers/sequences/list/list.ops/merge.pass.cpp +++ b/libcxx/test/std/containers/sequences/list/list.ops/merge.pass.cpp @@ -10,6 +10,7 @@ // // void merge(list& x); +// If (&addressof(x) == this) does nothing; otherwise ... #include #include @@ -26,7 +27,16 @@ int main() std::list c2(a2, a2+sizeof(a2)/sizeof(a2[0])); c1.merge(c2); assert(c1 == std::list(a3, a3+sizeof(a3)/sizeof(a3[0]))); + assert(c2.empty()); } + + { + int a1[] = {1, 3, 7, 9, 10}; + std::list c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + c1.merge(c1); + assert((c1 == std::list(a1, a1+sizeof(a1)/sizeof(a1[0])))); + } + #if TEST_STD_VER >= 11 { int a1[] = {1, 3, 7, 9, 10}; @@ -36,6 +46,7 @@ int main() std::list> c2(a2, a2+sizeof(a2)/sizeof(a2[0])); c1.merge(c2); assert((c1 == std::list>(a3, a3+sizeof(a3)/sizeof(a3[0])))); + assert(c2.empty()); } #endif } diff --git a/libcxx/test/std/containers/sequences/list/list.ops/merge_comp.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/merge_comp.pass.cpp index 838ff22..20ddbef 100644 --- a/libcxx/test/std/containers/sequences/list/list.ops/merge_comp.pass.cpp +++ b/libcxx/test/std/containers/sequences/list/list.ops/merge_comp.pass.cpp @@ -10,6 +10,7 @@ // // template void merge(list& x, Compare comp); +// If (&addressof(x) == this) does nothing; otherwise ... #include #include @@ -27,7 +28,15 @@ int main() std::list c2(a2, a2+sizeof(a2)/sizeof(a2[0])); c1.merge(c2, std::greater()); assert(c1 == std::list(a3, a3+sizeof(a3)/sizeof(a3[0]))); + assert(c2.empty()); } + { + int a1[] = {10, 9, 7, 3, 1}; + std::list c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + c1.merge(c1, std::greater()); + assert((c1 == std::list(a1, a1+sizeof(a1)/sizeof(a1[0])))); + } + #if TEST_STD_VER >= 11 { int a1[] = {10, 9, 7, 3, 1}; @@ -37,6 +46,7 @@ int main() std::list> c2(a2, a2+sizeof(a2)/sizeof(a2[0])); c1.merge(c2, std::greater()); assert((c1 == std::list>(a3, a3+sizeof(a3)/sizeof(a3[0])))); + assert(c2.empty()); } #endif } diff --git a/libcxx/www/cxx2a_status.html b/libcxx/www/cxx2a_status.html index d49f994..84ebb02 100644 --- a/libcxx/www/cxx2a_status.html +++ b/libcxx/www/cxx2a_status.html @@ -73,7 +73,7 @@ P0768R1CWGLibrary Support for the Spaceship (Comparison) OperatorAlbuquerque P0777R1LWGTreating Unnecessary decayAlbuquerqueComplete7.0 P0122R7LWG<span>JacksonvilleComplete7.0 - P0355R7LWGExtending chrono to Calendars and Time ZonesJacksonville + P0355R7LWGExtending chrono to Calendars and Time ZonesJacksonvilleIn progress P0551R3LWGThou Shalt Not Specialize std Function Templates!Jacksonville P0753R2LWGManipulators for C++ Synchronized Buffered OstreamJacksonville P0754R2LWG<version>JacksonvilleComplete7.0 @@ -89,7 +89,7 @@ P0476R2LWGBit-casting object representationsRapperswil P0528R3CWGThe Curious Case of Padding Bits, Featuring Atomic Compare-and-ExchangeRapperswil P0542R5CWGSupport for contract based programming in C++Rapperswil - P0556R3LWGIntegral power-of-2 operationsRapperswilIn Progress + P0556R3LWGIntegral power-of-2 operationsRapperswilIn ProgressIn progress P0619R4LWGReviewing Deprecated Facilities of C++17 for C++20Rapperswil P0646R1LWGImproving the Return Value of Erase-Like AlgorithmsRapperswil P0722R3CWGEfficient sized delete for variable sized classesRapperswil @@ -102,7 +102,7 @@ P0892R2CWGexplicit(bool)Rapperswil P0898R3LWGStandard Library ConceptsRapperswil P0935R0LWGEradicating unnecessarily explicit default constructors from the standard libraryRapperswil - P0941R2CWGIntegrating feature-test macros into the C++ WDRapperswil + P0941R2CWGIntegrating feature-test macros into the C++ WDRapperswilIn progress P1023R0LWGconstexpr comparison operators for std::arrayRapperswilComplete8.0 P1025R1CWGUpdate The Reference To The Unicode StandardRapperswil P1120R0CWGConsistency improvements for <=> and other comparison operatorsRapperswil @@ -187,7 +187,7 @@ 3013(recursive_)directory_iterator construction and traversal should not be noexceptJacksonvilleComplete 3014More noexcept issues with filesystem operationsJacksonvilleComplete 3015copy_options::unspecified underspecifiedJacksonvilleNothing to do - 3017list splice functions should use addressofJacksonville + 3017list splice functions should use addressofJacksonvilleComplete 3020[networking.ts] Remove spurious nested value_type buffer sequence requirementJacksonville 3026filesystem::weakly_canonical still defined in terms of canonical(p, base)JacksonvilleComplete 3030Who shall meet the requirements of try_lock?JacksonvilleNothing to do @@ -222,7 +222,7 @@ -

Last Updated: 27-Aug-2018

+

Last Updated: 11-Sep-2018

-- 2.7.4