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 // <unordered_set>
10
11 // Dereference non-dereferenceable iterator.
12
13 // REQUIRES: has-unix-headers, libcpp-hardening-mode={{extensive|debug}}
14 // UNSUPPORTED: c++03
15 // XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing
16
17 #include <unordered_set>
18
19 #include "check_assertion.h"
20 #include "min_allocator.h"
21
main(int,char **)22 int main(int, char**) {
23 {
24 typedef int T;
25 typedef std::unordered_set<T> C;
26 C c(1);
27 C::local_iterator i = c.end(0);
28 TEST_LIBCPP_ASSERT_FAILURE(
29 *i, "Attempted to dereference a non-dereferenceable unordered container const_local_iterator");
30 C::const_local_iterator i2 = c.cend(0);
31 TEST_LIBCPP_ASSERT_FAILURE(
32 *i2, "Attempted to dereference a non-dereferenceable unordered container const_local_iterator");
33 }
34
35 {
36 typedef int T;
37 typedef std::unordered_set<T, std::hash<T>, std::equal_to<T>, min_allocator<T>> C;
38 C c(1);
39 C::local_iterator i = c.end(0);
40 TEST_LIBCPP_ASSERT_FAILURE(
41 *i, "Attempted to dereference a non-dereferenceable unordered container const_local_iterator");
42 C::const_local_iterator i2 = c.cend(0);
43 TEST_LIBCPP_ASSERT_FAILURE(
44 *i2, "Attempted to dereference a non-dereferenceable unordered container const_local_iterator");
45 }
46
47 return 0;
48 }
49