False report for hidden functions on cpp 1242

Hello, thx in advance for the support!

This is reported in SonarQube v9.9 LTS
as " Correct these functions so that no function in “Child::example” hides a function in “Parent::example”.

Sample code:

class Parent
{
public:
    virtual void example(arg1, arg2, arg3)
    {
        // throw an error
    }
    virtual void example(arg4, arg5, arg6)
    {
        // throw an error
    }
    virtual void example(arg7, arg8, arg9)
    {
        // throw an error
    }
}
class Child: public Parent
{
public:
     void example( arg1, arg2, arg3) override;
     void example( arg4, arg5, arg6) override;
     void example( arg7, arg8, arg9) override;
}

Welcome to the communioty @Xrysafenia_MALLIA-ST.

The output of the rule S1242 that covers hiding of base class functions, tightly depends on the type of parameters.

In the case of the sample code you have provided, the code does not compile, as the types of arguments (arg1, to arg9) are not defined. Is this a reduced example from the code sample where the rule is raised? Would it be possible to provide us with a full code sample that reproduces an issue?

The most accurate option to represent your code would be to provide us reproducer for the file where the issue appeared, with information on which line the issue is. To generate the reproducer file:

  • Search in the analysis log for the full path of the source file for which you want to create a reproducer (for instance, a file that contains a false-positive). You will have to use exactly this name (same case, / or \…)
  • Add the reproducer option to the scanner configuration:
    sonar.cfamily.reproducer=“Full path to the .cpp”
  • Re-run the scanner to generate a file named sonar-cfamily.reproducer in the project folder.
  • Please share this file. If you think this file contains private information, let us know, and we’ll send you a private message that will allow you to send it privately.