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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 // the input reference stale). 452 // the input reference stale).
453 size_t limit = vector.capacity() + 1; 453 size_t limit = vector.capacity() + 1;
454 for (size_t i = 0; i < limit; i++) 454 for (size_t i = 0; i < limit; i++)
455 vector.append(vector.first()); 455 vector.append(vector.first());
456 456
457 limit = vector.capacity() + 1; 457 limit = vector.capacity() + 1;
458 for (size_t i = 0; i < limit; i++) 458 for (size_t i = 0; i < limit; i++)
459 vector.append(const_cast<const WTF::String&>(vector.first())); 459 vector.append(const_cast<const WTF::String&>(vector.first()));
460 } 460 }
461 461
462 // The test below is for the following issue:
463 //
464 // https://bugs.chromium.org/p/chromium/issues/detail?id=592767
465 //
466 // where deleted copy assignment operator made canMoveWithMemcpy true because of the implementation of
467 // IsTriviallyMoveAssignable<T>.
468
469 class MojoMoveOnlyType final {
yzshen1 2016/03/08 21:30:38 Nit: this class itself doesn't have anything to do
470 public:
471 MojoMoveOnlyType();
472 MojoMoveOnlyType(MojoMoveOnlyType&&);
473 MojoMoveOnlyType& operator=(MojoMoveOnlyType&&);
474 ~MojoMoveOnlyType();
475
476 private:
477 MojoMoveOnlyType(const MojoMoveOnlyType&) = delete;
478 void operator=(const MojoMoveOnlyType&) = delete;
479 };
480
481 static_assert(!IsTriviallyMoveAssignable<MojoMoveOnlyType>::value, "MojoMoveOnly Type isn't trivially move assignable.");
482 static_assert(!IsTriviallyCopyAssignable<MojoMoveOnlyType>::value, "MojoMoveOnly Type isn't trivially copy assignable.");
483
484 static_assert(!VectorTraits<MojoMoveOnlyType>::canMoveWithMemcpy, "MojoMoveOnlyT ype can't be moved with memcpy.");
485 static_assert(!VectorTraits<MojoMoveOnlyType>::canCopyWithMemcpy, "MojoMoveOnlyT ype can't be copied with memcpy.");
486
462 } // anonymous namespace 487 } // anonymous namespace
463 488
464 } // namespace WTF 489 } // namespace WTF
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698