varconst f0dfe682bc [libc++][hardening] Deprecate _LIBCPP_ENABLE_ASSERTIONS.
`_LIBCPP_ENABLE_ASSERTIONS` was used to enable the "safe" mode in
libc++. Libc++ now provides the hardened mode and the debug mode that
replace the safe mode.

For backward compatibility, enabling `_LIBCPP_ENABLE_ASSERTIONS` now
enables the hardened mode. Note that the hardened mode provides
a narrower set of checks than the previous "safe" mode (only
security-critical checks that are performant enough to be used in
production).

Differential Revision: https://reviews.llvm.org/D154997
2023-07-14 16:58:47 -07:00

42 lines
1.1 KiB
C++

//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// REQUIRES: has-unix-headers
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
// XFAIL: availability-verbose_abort-missing
// <mdspan>
// layout_left::mapping
//
// constexpr index_type stride(rank_type i) const noexcept;
//
// Constraints: extents_type::rank() > 0 is true.
//
// Preconditions: i < extents_type::rank() is true.
//
// Returns: extents().rev-prod-of-extents(i).
//
//
#include <mdspan>
#include <cassert>
#include "check_assertion.h"
int main(int, char**) {
// value out of range
{
std::layout_left::template mapping<std::dextents<int, 3>> m{std::dextents<int, 3>{100, 100, 100}};
TEST_LIBCPP_ASSERT_FAILURE(m.stride(4), "invalid rank index");
}
return 0;
}