S1238 pass large input parameters by const& for overridden methods

For rule S1238, which indicates when a const& is cheaper than a pass by value, in case of overridden methods, I think the warning should be raised on the base virtual method.
This is especially true when the base class is included from an external library. In this case, we have no way to fix the issue, and have to mark it as Won’t Fix.

We’re using SonarQube Data Center Edition Version 10.3 (build 82913).

The following code on Compiler Explorer should be enough to raise the warning.

I apologize if the issue has been raised before. I tried searching but came up empty.
Let me know if you think this makes sense.

Best regards,
Luís

Welcome to the community @satelliteprogrammer!

Thank you very much for the report. I agree that in the situation you have described, the issue raised by the rule is not really actionable. In that, marking it as “Won’t Fix” is the best option at this point.

We already have an issue for a similar problem with the other rules that require modification of the function signature CPP-5365, and I update the ticket to also apply to this rule. We are looking into a general solution to this problem. However, there is no specific timeline yet. You can check the ticket status to track it status.

1 Like