diff options
Diffstat (limited to 'libcxx/test/libcxx-03/assertions/modes/none.pass.cpp')
| -rw-r--r-- | libcxx/test/libcxx-03/assertions/modes/none.pass.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libcxx/test/libcxx-03/assertions/modes/none.pass.cpp b/libcxx/test/libcxx-03/assertions/modes/none.pass.cpp new file mode 100644 index 000000000000..e79dee906ae6 --- /dev/null +++ b/libcxx/test/libcxx-03/assertions/modes/none.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// This test checks that if no hardening mode is defined (i.e., in the unchecked mode), by default assertions aren't +// triggered. + +// REQUIRES: libcpp-hardening-mode=none + +#include <__cxx03/__assert> +#include <cassert> + +bool executed_condition = false; +bool f() { + executed_condition = true; + return false; +} + +int main(int, char**) { + _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(true, "Should not fire"); + _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "Also should not fire"); + _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(f(), "Should not execute anything"); + assert(!executed_condition); // Really make sure we did not execute anything. + + return 0; +} |
