struct D
{
virtual void m() const = 0;
};
struct D1 : public virtual D { };
struct D2 : public virtual D { };
struct B : public D2
{
B() { }
B(int val) : B() { }
void m() const { }
};
struct A : public B, public D1
{
A() : B(0) { }
};
int main()
{
A a;
return 0;
}
I get crash with MSVC 2013 compiler with above code. It runs without crash when compiled with GCC 4.7.2. Hierarchy of classes is depicted below.
D
/ \
D1 D2
| |
\ B
\ /
A
This is a bug in MS compiler or I made a mistake in the code?
As far as I can tell, your code example should work.
As an aside, though, your constructor delegation might be considered bad practice. You should have one fully defined constructor that all lesser defined constructor delegate to, not the other way around. For example: