Rule cpp:S1235 invalid for MSVC __interface


the C++ rule cpp:S1235 “Polymorphic base class destructor should be either public virtual or protected non-virtual” shows a false positive with this code example:

    __interface IRunner
        void Run() const;

    class Runner : public IRunner
        void Run() const override;

The rule will complain that the base class (IRunner) should have a virtual destructor. But we are using an __interface here, which is a Microsoft C++ extension, that already enforces this internally. It is not possible to provide a destructor in an __interface class. Microsoft documentation: __interface | Microsoft Learn

So in case an __interface is used, this rule should not be applied.

This was found in SonarQube 9.7.1.

Please let me know if you need more information.
Thanks and best regards

Hello @bmgen,

As you said, __interface is a Microsoft extension. We do not support this extension. I just added [CPP-4056] - Jira to add its support, but no ETA for now.

1 Like

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