The current code uses assertions with falsy literal values in a few places. This is perfectly fine, but this comes with a bit of confusion sometimes:
assert(false)may cause confusion when it is unclear ifNDEBUGcan disable it. (The intention is to disallowNDEBUGcompilation)Assert(false)hides the noreturn attribute behind a function call, which may cause GCC return-type warnings. (Clang seems to understand it) E.g. https://godbolt.org/z/e7bWsPn51- When C++23 will be allowed, devs may prefer
std::unreachable. However, this is unsafe and will invoke UB. - There is confusion why a
CHECK_NONFATALmacro exists, but no fatal equivalent.
Fix all those issues by:
- Adding the util/check.h include for all assertions to import the
NDEBUGcompile error. (scripted-diff + clang-format) - Adding a new
AssertUnreachable, which directly calls the noreturnassertion_failhelper. - Adding an
assert_falsylinter to enforce all code to use this macro. - Adding a linter to forbid
std::unreachable.