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 // <string> 10 11 // Index const string out of bounds. 12 13 // REQUIRES: has-unix-headers 14 // UNSUPPORTED: c++03 15 // UNSUPPORTED: libcpp-hardening-mode=none 16 // XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing 17 18 #include <string> 19 #include <cassert> 20 21 #include "check_assertion.h" 22 #include "min_allocator.h" 23 24 template <class S> test()25void test() { 26 const S s; 27 assert(s[0] == 0); 28 TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds"); 29 } 30 main(int,char **)31int main(int, char**) { 32 test<std::string>(); 33 test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >(); 34 35 return 0; 36 } 37