[PATCH] D26815: [libcxx] [test] Fix an assumption about the state of moved-from std::functions.

Stephan T. Lavavej via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 17 13:37:09 PST 2016


STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

[libcxx] [test] Fix an assumption about the state of moved-from std::functions.

The Standard doesn't provide any guarantees beyond "valid but unspecified" for
moved-from std::functions. libcxx moves from small targets and leaves them
there, while MSVC's STL empties out the source. Mark these assertions as
libcxx-specific.


https://reviews.llvm.org/D26815

Files:
  test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp


Index: test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp
===================================================================
--- test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp
+++ test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp
@@ -132,7 +132,7 @@
         assert(A::count == 1);
         assert(f2.target<A>() == nullptr);
         assert(f2.target<Ref>());
-        assert(f.target<Ref>()); // f is unchanged because the target is small
+        LIBCPP_ASSERT(f.target<Ref>()); // f is unchanged because the target is small
     }
     {
         // Test that moving a function constructed from a function pointer
@@ -146,7 +146,7 @@
         std::function<int(int)> f2(std::move(f));
         assert(f2.target<A>() == nullptr);
         assert(f2.target<Ptr>());
-        assert(f.target<Ptr>()); // f is unchanged because the target is small
+        LIBCPP_ASSERT(f.target<Ptr>()); // f is unchanged because the target is small
     }
 #endif  // TEST_STD_VER >= 11
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26815.78415.patch
Type: text/x-patch
Size: 1126 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161117/543a78bf/attachment.bin>


More information about the cfe-commits mailing list