Skip to content

Why is CodeQL C++ unable to find the asserted Expression in assert() if NDEBUG is defined ? #16538

Answered by jketema
Sixelayo asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @ayosten,

Thanks for your question.

So now seing this I don't even understand how CodeQL is able to know there's a assertion if NDEBUG is defined. That means CodeQL HAS to look at source code before preprocessor invocation.

Not quite. We simply record the macro invocations that affect the code/expression that ends up in your database.

And if so, why doesn't it also grab the Expression inside ?

Because the expression in not in the database when the code is compile with NDEBUG, instead there will be a ((void)0) in the database at the location of the assert. The ((void)0) statement will be the one to which the macro invocation is attached, or the be more precise: ((void)0) is generate…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Sixelayo
Comment options

Answer selected by Sixelayo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants