Howard Hinnant | 782da33 | 2013-03-25 22:12:26 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <vector> |
| 11 | |
| 12 | // Index const vector out of bounds. |
| 13 | |
Howard Hinnant | 5e57142 | 2013-08-23 20:10:18 +0000 | [diff] [blame] | 14 | #if _LIBCPP_DEBUG >= 1 |
Howard Hinnant | 782da33 | 2013-03-25 22:12:26 +0000 | [diff] [blame] | 15 | |
Howard Hinnant | 3fbd1df | 2013-03-26 14:28:25 +0000 | [diff] [blame] | 16 | #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) |
Howard Hinnant | 782da33 | 2013-03-25 22:12:26 +0000 | [diff] [blame] | 17 | |
| 18 | #include <vector> |
| 19 | #include <cassert> |
| 20 | #include <iterator> |
| 21 | #include <exception> |
| 22 | #include <cstdlib> |
| 23 | |
Marshall Clow | 061d0cc | 2013-11-26 20:58:02 +0000 | [diff] [blame] | 24 | #include "min_allocator.h" |
Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 +0000 | [diff] [blame] | 25 | |
Howard Hinnant | 782da33 | 2013-03-25 22:12:26 +0000 | [diff] [blame] | 26 | int main() |
| 27 | { |
Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 +0000 | [diff] [blame] | 28 | { |
Howard Hinnant | 782da33 | 2013-03-25 22:12:26 +0000 | [diff] [blame] | 29 | typedef int T; |
| 30 | typedef std::vector<T> C; |
| 31 | const C c(1); |
| 32 | assert(c[0] == 0); |
| 33 | assert(c[1] == 0); |
| 34 | assert(false); |
Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 +0000 | [diff] [blame] | 35 | } |
| 36 | #if __cplusplus >= 201103L |
| 37 | { |
| 38 | typedef int T; |
| 39 | typedef std::vector<T, min_allocator<T>> C; |
| 40 | const C c(1); |
| 41 | assert(c[0] == 0); |
| 42 | assert(c[1] == 0); |
| 43 | assert(false); |
| 44 | } |
| 45 | #endif |
Howard Hinnant | 782da33 | 2013-03-25 22:12:26 +0000 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | #else |
| 49 | |
| 50 | int main() |
| 51 | { |
| 52 | } |
| 53 | |
| 54 | #endif |