Skip to content

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

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 5 commits into from
May 20, 2024

Conversation

codeqlhelper
Copy link
Contributor

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

Static variables are initialized to zero or null by compiler, no need to get an initializer of them
@codeqlhelper codeqlhelper requested a review from a team as a code owner May 19, 2024 13:50
@github-actions github-actions bot added the C++ label May 19, 2024
@codeqlhelper codeqlhelper changed the title Static variables are initialized to zero or null by compiler C++: Static variables are initialized to zero or null by compiler May 19, 2024
MathiasVP
MathiasVP previously approved these changes May 20, 2024
Copy link
Contributor

@MathiasVP MathiasVP left a comment

Choose a reason for hiding this comment

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

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 MathiasVP merged commit c483a4b into github:main 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
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