Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Unified Diff: third_party/WebKit/Source/wtf/VectorTest.cpp

Issue 1771303002: WTF: Fix Vector<T> memcpy'ing incorrectly for some T. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final MSVC workaround. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/wtf/VectorTest.cpp
diff --git a/third_party/WebKit/Source/wtf/VectorTest.cpp b/third_party/WebKit/Source/wtf/VectorTest.cpp
index d06b47be7bf0215dc50edbf1bd1879bc0b504fef..447edd090448b5c7f5577b89cf19a7ba7a08c134 100644
--- a/third_party/WebKit/Source/wtf/VectorTest.cpp
+++ b/third_party/WebKit/Source/wtf/VectorTest.cpp
@@ -459,6 +459,31 @@ TEST(VectorTest, AppendFirst)
vector.append(const_cast<const WTF::String&>(vector.first()));
}
+// The test below is for the following issue:
+//
+// https://bugs.chromium.org/p/chromium/issues/detail?id=592767
+//
+// where deleted copy assignment operator made canMoveWithMemcpy true because of the implementation of
+// IsTriviallyMoveAssignable<T>.
+
+class MojoMoveOnlyType final {
+public:
+ MojoMoveOnlyType();
+ MojoMoveOnlyType(MojoMoveOnlyType&&);
+ MojoMoveOnlyType& operator=(MojoMoveOnlyType&&);
+ ~MojoMoveOnlyType();
+
+private:
+ MojoMoveOnlyType(const MojoMoveOnlyType&) = delete;
+ void operator=(const MojoMoveOnlyType&) = delete;
+};
+
+static_assert(!IsTriviallyMoveAssignable<MojoMoveOnlyType>::value, "MojoMoveOnlyType isn't trivially move assignable.");
+static_assert(!IsTriviallyCopyAssignable<MojoMoveOnlyType>::value, "MojoMoveOnlyType isn't trivially copy assignable.");
+
+static_assert(!VectorTraits<MojoMoveOnlyType>::canMoveWithMemcpy, "MojoMoveOnlyType can't be moved with memcpy.");
+static_assert(!VectorTraits<MojoMoveOnlyType>::canCopyWithMemcpy, "MojoMoveOnlyType can't be copied with memcpy.");
+
} // anonymous namespace
} // namespace WTF

Powered by Google App Engine
This is Rietveld 408576698