Skip to content

Fix #13944 fn constparameterpointer#8240

Open
ceJce wants to merge 3 commits intodanmar:mainfrom
ceJce:fix13944_fp_constparameterpointer
Open

Fix #13944 fn constparameterpointer#8240
ceJce wants to merge 3 commits intodanmar:mainfrom
ceJce:fix13944_fp_constparameterpointer

Conversation

@ceJce
Copy link
Contributor

@ceJce ceJce commented Feb 19, 2026

class C : public QObject
{
public:
void func01(QPoint* pt) { // <- pt can be const
if (nullptr == pt) {}
}
};

The fix adds inconclusive warning for this case, including tests.

Add inconclusive and default=false (instead of true) in checkConstPointer.
@chrchr-github
Copy link
Collaborator

IMHO we should follow the approach used for https://trac.cppcheck.net/ticket/13282
"Either there is a missing override, or the parameter 'x' can be const."
Just making the warning inconclusive tells the user nothing.

@ceJce
Copy link
Contributor Author

ceJce commented Feb 19, 2026

IMHO we should follow the approach used for https://trac.cppcheck.net/ticket/13282 "Either there is a missing override, or the parameter 'x' can be const." Just making the warning inconclusive tells the user nothing.

Can you clarify what you object of? The inconclusion part or the warning?

Before it was no warning at all, now there is but inconclusive is added since the check failed to find the base class. The inconclusion part was suggested by Daniel M.

if (foundAllBaseClasses) //If we've seen all the base classes and none of the above were true then it must not be virtual
return false;
return defaultVal; //If we can't see all the bases classes then we can't say conclusively
//If we can't see all the bases classes then we can't say conclusively, set inconclusive (if possible) and return default value
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't inconclusive redundant since there is pFoundAllBaseClasses already?

@sonarqubecloud
Copy link

@chrchr-github
Copy link
Collaborator

IMHO we should follow the approach used for https://trac.cppcheck.net/ticket/13282 "Either there is a missing override, or the parameter 'x' can be const." Just making the warning inconclusive tells the user nothing.

Can you clarify what you object of? The inconclusion part or the warning?

Before it was no warning at all, now there is but inconclusive is added since the check failed to find the base class. The inconclusion part was suggested by Daniel M.

The warning should have the "either ... or" format, and be inconclusive.

@danmar
Copy link
Owner

danmar commented Feb 19, 2026

I agree the warning message can be clarified and it would be good to be somewhat consistent..

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

Comments