Skip to content

Fix #11713 FN constParameterPointer/Reference with unused parameter#6085

Merged
chrchr-github merged 11 commits intocppcheck-opensource:mainfrom
chrchr-github:chr_Fix11713
Mar 8, 2024
Merged

Fix #11713 FN constParameterPointer/Reference with unused parameter#6085
chrchr-github merged 11 commits intocppcheck-opensource:mainfrom
chrchr-github:chr_Fix11713

Conversation

@chrchr-github
Copy link
Copy Markdown
Collaborator

No description provided.

@chrchr-github
Copy link
Copy Markdown
Collaborator Author

I wonder how much noise this will cause.
But we already warn for

int f(int& r) {
	int i = r;
#ifdef MACRO
	r = 0;
#endif
	return i;
}

@danmar
Copy link
Copy Markdown
Collaborator

danmar commented Mar 8, 2024

But we already warn for

I also classify that as a false positive. I would prefer that we fix such FPs... if there are ifdefs and stuff in the scope that could hide code then do not warn.

However I would suggest that the "possible FP" warnings are still reported in such cases with a separate ID (maybe enabled by --inconclusive).

Comment thread lib/checkother.cpp Outdated
@firewave
Copy link
Copy Markdown
Collaborator

firewave commented Mar 8, 2024

I also classify that as a false positive. I would prefer that we fix such FPs... if there are ifdefs and stuff in the scope that could hide code then do not warn.

I do not agree. IMO that is the point of analyzing multiple configurations.

int f() {
	int i; // unassigned
#ifdef MACRO
	i = 0;
#endif
	return i; // uninitialized
}

In that case we correctly detect the unassigned variable and the uninitialized one. Not reporting it in the case this PR addresses would be inconsistent and thus unexpected.

@chrchr-github chrchr-github merged commit 54f46d3 into cppcheck-opensource:main Mar 8, 2024
@chrchr-github chrchr-github deleted the chr_Fix11713 branch March 8, 2024 14:48
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