C++: Static variables are initialized to zero or null by compiler#16527
Merged
MathiasVP merged 5 commits intogithub:mainfrom May 20, 2024
Merged
C++: Static variables are initialized to zero or null by compiler#16527MathiasVP merged 5 commits intogithub:mainfrom
MathiasVP merged 5 commits intogithub:mainfrom
Conversation
Static variables are initialized to zero or null by compiler, no need to get an initializer of them
MathiasVP
previously approved these changes
May 20, 2024
Contributor
There was a problem hiding this comment.
Hi @codeqlhelper,
Thanks for your contribution ❤️ I hope you don't mind that I pushed a few administrative commits to the PR:
- I updated the change note to be more aligned with the way we normally phrase FP removals
- I added a very minimal set of tests to this query since I couldn't find any tests for it (😱) and we like to have tests in place for changes like this.
- The query had to be autoformatted to match our style guide (see here)
Everything LGTM now!
MathiasVP
approved these changes
May 20, 2024
codeqlhelper
added a commit
to codeqlhelper/codeql
that referenced
this pull request
Jul 27, 2025
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
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 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