1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // <vector> 10 11 // Index vector out of bounds. 12 13 // REQUIRES: has-unix-headers 14 // UNSUPPORTED: c++03 15 // XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx{{10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0|12.0}} 16 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1 17 18 #include <vector> 19 #include <cassert> 20 21 #include "check_assertion.h" 22 #include "min_allocator.h" 23 main(int,char **)24int main(int, char**) { 25 { 26 typedef int T; 27 typedef std::vector<T, min_allocator<T> > C; 28 C c(1); 29 assert(c[0] == 0); 30 TEST_LIBCPP_ASSERT_FAILURE(c[1], "vector[] index out of bounds"); 31 } 32 33 { 34 typedef int T; 35 typedef std::vector<T> C; 36 C c(1); 37 assert(c[0] == 0); 38 TEST_LIBCPP_ASSERT_FAILURE(c[1], "vector[] index out of bounds"); 39 } 40 41 return 0; 42 } 43