CodeQL library for C/C++
codeql/cpp-all 0.7.2 ( changelog , source )

Module Assertions

Import path

import semmle.code.cpp.commons.Assertions



Provides classes and predicates for working with C/C++ code.



An assertion, that is, a condition that is only false if there is a bug in the program. To add support for more, define additional subclasses. A typical subclass will extend extend either MacroInvocation (for assertion macros) or FunctionCall (for assertion functions).


A libc assert, as defined in assert.h. A macro with a head that matches the prefix “assert(”, and expands to a conditional expression which may terminate the program.


A macro assert that expands to an if statement; the head is taken to be “Assert(x, y)”, but further alternatives could be added.


An assertion that is not completely disabled in release builds but returns a Boolean value to enable recovery from unexpected anomalous behavior. This style of assert is advocated by the Power of 10 rules and the NASA JPL Coding Standard.