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 // This test checks that if no hardening mode is defined (i.e., in the unchecked mode), by default assertions aren't 10 // triggered. 11 12 // REQUIRES: libcpp-hardening-mode=none 13 14 #include <cassert> 15 16 bool executed_condition = false; f()17bool f() { 18 executed_condition = true; 19 return false; 20 } 21 main(int,char **)22int main(int, char**) { 23 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(true, "Should not fire"); 24 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "Also should not fire"); 25 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(f(), "Should not execute anything"); 26 assert(!executed_condition); // Really make sure we did not execute anything. 27 28 return 0; 29 } 30