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>
diff --git a/tests/TemplatesTest.cpp b/tests/TemplatesTest.cpp
index fc3bc32..9d5ca77 100644
--- a/tests/TemplatesTest.cpp
+++ b/tests/TemplatesTest.cpp
@@ -126,3 +126,20 @@
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
+}