From e32aed8014bf78f000d2ce16569fe7d46b488c62 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sat, 24 Dec 2016 03:27:52 +0000 Subject: [PATCH] Fix ASAN test failure git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@290482 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/libcxx/containers/sequences/vector/asan.pass.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/libcxx/containers/sequences/vector/asan.pass.cpp b/test/libcxx/containers/sequences/vector/asan.pass.cpp index d3604f0c3..db337e6b2 100644 --- a/test/libcxx/containers/sequences/vector/asan.pass.cpp +++ b/test/libcxx/containers/sequences/vector/asan.pass.cpp @@ -38,7 +38,8 @@ int main() const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; C c(std::begin(t), std::end(t)); c.reserve(2*c.size()); - T foo = c[c.size()]; // bad, but not caught by ASAN + volatile T foo = c[c.size()]; // bad, but not caught by ASAN + ((void)foo); } #endif @@ -64,6 +65,7 @@ int main() assert(!__sanitizer_verify_contiguous_container( c.data(), c.data() + 1, c.data() + c.capacity())); volatile T foo = c[c.size()]; // should trigger ASAN. Use volatile to prevent being optimized away. assert(false); // if we got here, ASAN didn't trigger + ((void)foo); } } #else