mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-27 05:37:21 -05:00
CAF_ASSERT was unconditionally active in every build configuration. Make it follow the semantics of the standard assert(): active in Debug, compiled out in optimized builds (NDEBUG). Add the CMake option RESINSIGHT_ENABLE_ASSERTS_IN_RELEASE (default OFF) for developers who want the asserts to stay active in an optimized build, which is useful when reproducing a problem in RelWithDebInfo with a debugger attached. When compiled out, the expression is kept inside an unevaluated sizeof rather than discarded. It is not evaluated, so there is no run-time cost and no side effects, but it is still type checked and any variable used only by the assert still counts as referenced, avoiding a wave of unused-variable warnings. CAF_ENABLE_ASSERTS is given a default in cafAssert.h so the header stays self-contained and include order can never silently switch the asserts off. Document in docs/agents/coding-style.md that CAF_ASSERT is the assert to use, that CVF_ASSERT is legacy, and that asserts are for broken invariants rather than for run-time conditions that need real error handling.