cpp:S1242 false positive when overriding a function already declared pure virtual

I’m using SonarLint in JetBrains’ CLion and it keeps telling me to avoid shadowing inherited function sound() or to declare it virtual. Problem is that it’s already virtual, pure virtual to be exact, so I believe this is a false positive.

    std::string who() const;
    virtual std::string sound() const = 0;

    Animal(std::string name, int weight) :
    m_name{name}, m_weight{weight} {}

    std::string m_name;
    int m_weight;

class Sheep : public Animal{
    using Animal::Animal;
    std::string sound() const override;

Hello @Thomas_Herondale,

Which compiler are you using with CLion?
I don’t reproduce it on my side so It might be a configuration issue instead of a rule implementation issue.


Hi @Abbas_Sabra!
I’m currently using the Visual Studio Compiler (version 16.0).

Thanks for your answer,


That was identified and fixed CPP-3289.

The problem is in finding the STL headers with Visual Studio Compilers. So you might face some false positives/negatives because of that. The fix should be available with SonarLint next release.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.