Skip to content

Fix #13812 value potentially truncated in ValueFlowAnalyzer::evaluteInt()#8482

Merged
chrchr-github merged 4 commits intodanmar:mainfrom
chrchr-github:chr_13812
Apr 23, 2026
Merged

Fix #13812 value potentially truncated in ValueFlowAnalyzer::evaluteInt()#8482
chrchr-github merged 4 commits intodanmar:mainfrom
chrchr-github:chr_13812

Conversation

@chrchr-github
Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread lib/vf_analyzers.cpp
@chrchr-github chrchr-github marked this pull request as ready for review April 23, 2026 14:06
Comment thread test/testvalueflow.cpp

#define testValueOfX(...) testValueOfX_(__FILE__, __LINE__, __VA_ARGS__)
bool testValueOfX_(const char* file, int line, const char code[], unsigned int linenr, int value, const Settings *s = nullptr) {
bool testValueOfX_(const char* file, int line, const char code[], unsigned int linenr, MathLib::bigint value, const Settings *s = nullptr) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This smells like it should have been reported by one of the compiler warnings we have disabled...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Maybe, but so far all tests used only values in the int range.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The comparison between value and Value::intvalue below should have triggered one for sure. That would be a different one from the implicit conversion the call would have done.

firewave
firewave previously approved these changes Apr 23, 2026
Comment thread lib/vf_analyzers.cpp
MathLib::bigint out = 0;
if (pm.getContainerEmptyValue(tok->exprId(), out))
return {static_cast<int>(out)};
return {out};
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Harmless but unnecessary (out is effectively a bool).

@sonarqubecloud
Copy link
Copy Markdown

@chrchr-github chrchr-github merged commit 55493d0 into danmar:main Apr 23, 2026
72 checks passed
@chrchr-github chrchr-github deleted the chr_13812 branch April 23, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants