From 58c26b616cc5f7bcbff84bf349d4bdd3ab366080 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 1 Jan 2018 16:40:56 -0700 Subject: [PATCH] ircd: Update README note on assert(). --- include/ircd/README.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/include/ircd/README.md b/include/ircd/README.md index f762fa230..144758cd4 100644 --- a/include/ircd/README.md +++ b/include/ircd/README.md @@ -69,5 +69,16 @@ which count characters printed *not including null*. They may return a - Consider any code inside a runtime `assert()` statement to **entirely** disappear in optimized builds. Some implementations of `assert()` may only elide the boolean check and thus preserve the inner statement and the effects -of its execution. We do not rely on this. Consider `assert()` to be a -preprocessor macro like assert(*actual characters entirely erased*). +of its execution. We do not rely on this. Do not use `assert()` to check +return values of statements that need to be executed in optimized builds. + +- Furthermore, consider the **assert statement itself to be physically erased** +from the code during optimized builds. Thus the following is a big mistake: + +``` + if(foo) + assert(!bar); + + if(baz) + bam(); +```