3 ms·
Not all undefined behavior can be caught at compile time. However, LLVM and GCC can detect a lot of undefined behavior at runtime with ubsan. I'm not sure how
by telotortium 10y ago
Not all undefined behavior can be caught at compile time.
However, LLVM and GCC can detect a lot of undefined behavior at runtime with ubsan. I'm not sure how much performance penalty there is. Presumably checks are added on every signed integer arithmetic operation, pointer dereference, etc., but some checks can probably be removed by the optimizer (for example, a branch may be taken if a pointer is not null, which means the optimizer can remove all null checks in that branch as long as the pointer hasn't been modified).
Edit: oops, I missed the part where you said you're aware of sanitizers.