Skip to content

Valueflow: support global static const variables - #1861

Merged
danmar merged 1 commit into
cppcheck-opensource:masterfrom
rikardfalkeborn:valueflow-global-static-const
Jun 29, 2019
Merged

danmar merged 1 commit into
cppcheck-opensource:masterfrom
rikardfalkeborn:valueflow-global-static-const

Conversation

@rikardfalkeborn

Copy link
Copy Markdown
Contributor

No description provided.

@danmar

danmar commented May 31, 2019

Copy link
Copy Markdown
Collaborator

not sure.. will it only check const variables?

how do you handle code like:

static int x = 3;
void f1() { x = 43; }
void f2() { a = x; } // <- x does not have a known value

to determine the value of x we need to know if f1 will be called before f2 or not.

@rikardfalkeborn

Copy link
Copy Markdown
Contributor Author

Yes, it will only check const variables (isConst() is required three lines below)

@rikardfalkeborn

Copy link
Copy Markdown
Contributor Author

The case you mention is (somewhat) tested in valueFlowGlobalStaticVar() https://github.com/danmar/cppcheck/blob/5d10b57b04eb1c0123ad2c682dc49c964f68ce08/test/testvalueflow.cpp#L3241

@danmar

danmar commented Jun 2, 2019

Copy link
Copy Markdown
Collaborator

I will merge this after the release.

@orbitcowboy orbitcowboy added the merge-after-next-release Wait with merging this PR until after the next Release label Jun 2, 2019
@danmar
danmar merged commit d1d622b into cppcheck-opensource:master Jun 29, 2019
@rikardfalkeborn
rikardfalkeborn deleted the valueflow-global-static-const branch June 29, 2019 12:35
jubnzv pushed a commit to jubnzv/cppcheck that referenced this pull request Nov 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-after-next-release Wait with merging this PR until after the next Release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants