Page 1 of 1

Warning 1538 triggered for interface base classes without data

Posted: Tue Oct 13, 2020 10:12 am
by Sebastian
We have a lot of abstract classes used as interface classes that are used as base classes.
PC Lint triggers warning 1538 also when such a abstract class ist used as the base class.
Some (bad) simplified example code:

Code: Select all

class c1
{
public:
    virtual ~c1() {};
    virtual int a() = 0;
};

class c2 : public c1
{
public:
    c2() {}
    c2(const c2& /*src*/)
    {
    }
    virtual ~c2(){};
    int a() override {return 1;}
};

int main()
{
    c2 c2Instance;
    return 0;
}
Triggers this warning in the online demo:

Code: Select all

warning 1538: base class 'c1' absent from initializer list for copy constructor
Is it intentional that warning 1538 is triggered in such cases?
Is it a good practice to add the base class to the initializer list even in such a case?
If not, how to best suppress warning 1538?