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// REQUIRES: has-unix-headers
10// UNSUPPORTED: c++03
11// UNSUPPORTED: libcpp-hardening-mode=none
12// XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing
13
14// test that array<T, 0>::back() triggers an assertion
15
16#include <array>
17
18#include "check_assertion.h"
19
20int main(int, char**) {
21 {
22 typedef std::array<int, 0> C;
23 C c = {};
24 C const& cc = c;
25 TEST_LIBCPP_ASSERT_FAILURE(c.back(), "cannot call array<T, 0>::back() on a zero-sized array");
26 TEST_LIBCPP_ASSERT_FAILURE(cc.back(), "cannot call array<T, 0>::back() on a zero-sized array");
27 }
28 {
29 typedef std::array<const int, 0> C;
30 C c = {{}};
31 C const& cc = c;
32 TEST_LIBCPP_ASSERT_FAILURE(c.back(), "cannot call array<T, 0>::back() on a zero-sized array");
33 TEST_LIBCPP_ASSERT_FAILURE(cc.back(), "cannot call array<T, 0>::back() on a zero-sized array");
34 }
35
36 return 0;
37}
38

source code of libcxx/test/std/containers/sequences/array/assert.back.pass.cpp