Partial fix for 9049: False negative: uninitialized variable with nested ifs#8680
Open
pfultz2 wants to merge 24 commits into
Open
Partial fix for 9049: False negative: uninitialized variable with nested ifs#8680pfultz2 wants to merge 24 commits into
pfultz2 wants to merge 24 commits into
Conversation
firewave
reviewed
Jun 29, 2026
Comment on lines
+2233
to
+2234
| if (Token::Match(ftok, "exit|abort")) | ||
| return true; |
Collaborator
There was a problem hiding this comment.
There is also terminate() but it feels like should already be handled via the noreturn handling below (i.e. library configuration).
firewave
reviewed
Jun 29, 2026
| const bool inElse = scope->type == ScopeType::eElse; | ||
| const bool inDoWhile = scope->type == ScopeType::eDo; | ||
| const bool inLoop = contains({ScopeType::eDo, ScopeType::eFor, ScopeType::eWhile}, scope->type); | ||
| const bool hasElse = Token::simpleMatch(tok, "} else {"); |
Collaborator
There was a problem hiding this comment.
Since it is grouped with other similar variables this is fine but in a future we should try to reduce the scope of this (i.e. avoid computing them until they are used).
Contributor
Author
There was a problem hiding this comment.
It was moved here so its not calculated multiple times. Probably could use the memoize function to lazily compute it once, but I think its beyond the scope here because I need to evaluate if its slower or not.
Collaborator
|
The comments and the description appear to hint at AI assistance. Is that the case? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes the case for this:
Which doesnt use a compund condition
dimensions >= 1 && b)and it also requires complete variables and functions. The compund condition could be handled in the future by forking within the condition, soif(a && b) { ... }can be treated asif(a) { if(b) { ... }}.Here is a summary of the changes: