From 61b9a7258a7693d7f3674a5a1daf7b036ff1d382 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 6 Sep 2015 18:46:46 +0000 Subject: Import libc++ 3.7.0 release (r246257). --- test/std/containers/sequences/vector/asan.pass.cpp | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 test/std/containers/sequences/vector/asan.pass.cpp (limited to 'test/std/containers/sequences/vector/asan.pass.cpp') diff --git a/test/std/containers/sequences/vector/asan.pass.cpp b/test/std/containers/sequences/vector/asan.pass.cpp new file mode 100644 index 0000000000000..86c02b295624e --- /dev/null +++ b/test/std/containers/sequences/vector/asan.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// reference operator[](size_type n); + +#include +#include +#include + +#include "min_allocator.h" +#include "asan_testing.h" + +#ifndef _LIBCPP_HAS_NO_ASAN +extern "C" void __asan_set_error_exit_code(int); + +int main() +{ +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> C; + 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 + } +#endif + + __asan_set_error_exit_code(0); + { + typedef int T; + typedef std::vector C; + 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()); + assert(is_contiguous_container_asan_correct(c)); + assert(!__sanitizer_verify_contiguous_container ( c.data(), c.data() + 1, c.data() + c.capacity())); + T foo = c[c.size()]; // should trigger ASAN + assert(false); // if we got here, ASAN didn't trigger + } +} +#else +int main () { return 0; } +#endif -- cgit v1.2.3