Skip to content

C++: Static variables are initialized to zero or null by compiler #20129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 4, 2025

Conversation

codeqlhelper
Copy link
Contributor

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

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
@codeqlhelper codeqlhelper requested a review from a team as a code owner July 27, 2025 15:51
@github-actions github-actions bot added the C++ label Jul 27, 2025
codeqlhelper and others added 2 commits July 30, 2025 18:36
CPP: Add .expected file for the InitialisationNotRun test
…al-variable.md

Co-authored-by: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@geoffw0 geoffw0 merged commit 6925d4e into github:main Aug 4, 2025
16 checks passed
@geoffw0
Copy link
Contributor

geoffw0 commented Aug 4, 2025

@jketema FYI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants