brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · b9dec01 Raw
38 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// REQUIRES: has-unix-headers10// UNSUPPORTED: c++0311// UNSUPPORTED: libcpp-hardening-mode=none12// XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing13 14// test that array<T, 0>::back() triggers an assertion15 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