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 // UNSUPPORTED: c++03, windows
14 // UNSUPPORTED: use_system_cxx_lib && target={{.+}}-apple-macosx{{10.9|10.10|10.11|10.12|10.13|10.14|10.15|11|12}}
15 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
16 
17 #include <vector>
18 #include <cassert>
19 
20 #include "check_assertion.h"
21 #include "min_allocator.h"
22 
23 int main(int, char**) {
24   {
25     typedef int T;
26     typedef std::vector<T, min_allocator<T> > C;
27     C c(1);
28     assert(c[0] == 0);
29     TEST_LIBCPP_ASSERT_FAILURE(c[1], "vector[] index out of bounds");
30   }
31 
32   {
33     typedef int T;
34     typedef std::vector<T> C;
35     C c(1);
36     assert(c[0] == 0);
37     TEST_LIBCPP_ASSERT_FAILURE(c[1], "vector[] index out of bounds");
38   }
39 
40   return 0;
41 }
42