Consider a function
void f() {
assert(condition);
...
}
In debug mode, where asserts are enabled, the compiler is free to assume condition
holds, since the remaining code will not be executed if it does not.
However, in release mode, I believe the compiler will only see
void f() {
...
}
and can no longer assume condition
.
Are there any compiler directives or static assert tricks to let compiler know about certain invariants?