aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/TemplatesTest.cpp
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-04-07 14:18:29 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-07 19:06:12 +0000
commit149e42ed194e09ed273a131cd25d0d4a4a1fe64b (patch)
tree044f9a649e00f44f90d6cef52f001e2c8996bad0 /tests/TemplatesTest.cpp
parent266dcb05995e2c06544c4a1456264bd9b86180f8 (diff)
make SkAutoTMalloc self-move safe
We were just combing through possible changes that might have affected the attached bug, this popped out as pretty obviously unsafe. This doesn't explain the Chrome bug... SkAutoTMalloc and SKAutoSTMalloc are separate types. :( The new test fails and crashes before, passes after. Change-Id: I033f488a7f644b7a70e612c8535fedfac35c76db Reviewed-on: https://skia-review.googlesource.com/11797 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Herb Derby <herb@google.com>
Diffstat (limited to 'tests/TemplatesTest.cpp')
-rw-r--r--tests/TemplatesTest.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/TemplatesTest.cpp b/tests/TemplatesTest.cpp
index fc3bc320af..9d5ca7735f 100644
--- a/tests/TemplatesTest.cpp
+++ b/tests/TemplatesTest.cpp
@@ -126,3 +126,20 @@ DEF_TEST(AutoReallocToZero, reporter) {
test_realloc_to_zero<SkAutoTMalloc<int> >(reporter);
test_realloc_to_zero<SkAutoSTMalloc<kStackPreallocCount, int> >(reporter);
}
+
+DEF_TEST(SkAutoTMallocSelfMove, r) {
+#if defined(__clang__)
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wself-move"
+#endif
+
+ SkAutoTMalloc<int> foo(20);
+ REPORTER_ASSERT(r, foo.get());
+
+ foo = std::move(foo);
+ REPORTER_ASSERT(r, foo.get());
+
+#if defined(__clang__)
+ #pragma clang diagnostic pop
+#endif
+}