C++: Static variables are initialized to zero or null by compiler#20129
Merged
geoffw0 merged 9 commits intogithub:mainfrom Aug 4, 2025
Merged
C++: Static variables are initialized to zero or null by compiler#20129geoffw0 merged 9 commits intogithub:mainfrom
geoffw0 merged 9 commits intogithub:mainfrom
Conversation
Static variables are initialized to zero or null by compiler, no need to get an initializer of them. See https://stackoverflow.com/questions/13251083/the-initialization-of-static-variables-in-c See 6.7.8/10 in the C99 Standard. A relevant PR: github#16527
geoffw0
reviewed
Jul 28, 2025
cpp/ql/src/change-notes/2025-07-27-avoid-reporting-static-global-variable.md
Outdated
Show resolved
Hide resolved
cpp/ql/test/query-tests/Critical/InitialisationNotRun/InitialisationNotRun.qlref
Show resolved
Hide resolved
CPP: Add .expected file for the InitialisationNotRun test
…al-variable.md Co-authored-by: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
cpp/ql/test/query-tests/Critical/InitialisationNotRun/InitialisationNotRun.qlref
Dismissed
Show dismissed
Hide dismissed
geoffw0
approved these changes
Aug 4, 2025
Contributor
geoffw0
left a comment
There was a problem hiding this comment.
Happy with this.
- CI is passing.
- DCA shows 7088 results have been removed - in line with the intent of this PR.
- I did a small local + MRVA run and the lost results all look as expected (i.e. static variables) while the remaining results are not.
- I don't believe the query is in any standard suite.
Contributor
|
@jketema FYI. |
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.
Static variables are initialized to zero or null by compilers; there is no need to get an initializer for them.
See https://stackoverflow.com/questions/13251083/the-initialization-of-static-variables-in-c
See 6.7.8/10 in the C99 Standard
Please see a relevant PR: #16527