Skip to content

Fix FP returnTempReference#4793

Merged
orbitcowboy merged 6 commits intocppcheck-opensource:mainfrom
chrchr-github:chr_TempRef
Feb 17, 2023
Merged

Fix FP returnTempReference#4793
orbitcowboy merged 6 commits intocppcheck-opensource:mainfrom
chrchr-github:chr_TempRef

Conversation

@chrchr-github
Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread lib/symboldatabase.cpp Outdated
if (var.nameToken())
valuetype.bits = var.nameToken()->bits();
valuetype.pointer = (var.valueType() && var.valueType()->container) ? 0 : var.dimensions().size();
valuetype.pointer = (var.valueType() && var.valueType()->container && Token::simpleMatch(var.typeStartToken(), "std :: array")) ? 0 : var.dimensions().size();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What about std::array<int, 4> x[2]? That should be a pointer.

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.

That line was added in 271ccbc
For std::array<int, 4> x[2], there is no information about the C array (size 2) available in ValueType. var.dimensions() stores the std::array size 4, so we used to set pointer to 1 by accident.
It's almost like we shouldn't have mashed pointers, arrays, and std::arrays together in the first place...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yea I agree. I assume there is no issue with boost::array since we don't treat it like a C array.

@orbitcowboy orbitcowboy merged commit 1c11d30 into cppcheck-opensource:main Feb 17, 2023
@chrchr-github chrchr-github deleted the chr_TempRef branch March 13, 2023 11:35
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.

3 participants