I'm not sure if I'm missing something here but it seems that the following code (a similar one can be found into another answer I can no longer find, the question here is different by the way) is compiling just fine for clang and not compiling for gcc
#include <iostream>
using namespace std;
class base {
public:
base(int i) {};
private:
base(){};
};
class derivedA: virtual public base {
public:
derivedA(int i) : base(i) {};
protected:
derivedA() : base(0) {};
};
class derivedB: virtual public base {
public:
derivedB(int i) : base(i) {};
protected:
derivedB() : base(0) {};
};
class derivedAB : public derivedA, public derivedB {
public:
derivedAB(int i) {};
virtual ~derivedAB() = 0;
};
derivedAB::~derivedAB() {};
class lastDerived : public derivedAB {
public:
lastDerived() : base(1), derivedAB(0) {};
};
int main(){
lastDerived obj;
}
gcc is reporting
main.cpp: In constructor 'derivedAB::derivedAB(int)':
main.cpp:9:2: error: 'base::base()' is private
base(){};
Which one is the correct behavior? I'd say gcc's one but I'm not sure why.