db_cindex.pass.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. // <string>
  9. // Index const string out of bounds.
  10. #if _LIBCPP_DEBUG >= 1
  11. #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
  12. #include <string>
  13. #include <cassert>
  14. #include <iterator>
  15. #include <exception>
  16. #include <cstdlib>
  17. #include "test_macros.h"
  18. #include "min_allocator.h"
  19. int main(int, char**)
  20. {
  21. {
  22. typedef std::string S;
  23. const S s;
  24. assert(s[0] == 0);
  25. assert(s[1] == 0);
  26. assert(false);
  27. }
  28. #if TEST_STD_VER >= 11
  29. {
  30. typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
  31. const S s;
  32. assert(s[0] == 0);
  33. assert(s[1] == 0);
  34. assert(false);
  35. }
  36. #endif
  37. }
  38. #else
  39. int main(int, char**)
  40. {
  41. return 0;
  42. }
  43. #endif