Other Parts Discussed in Thread: MSP-EXP432E401Y
Tool/software: TI C/C++ Compiler
I am having a problem with virtual inheritance of a common ancestor and was wondering if anyone had seen the same issue or know of a workaround.
I have four int attributes in the base class that get initialised to 0 in the base class but upon completion of instantiation the four variables contain random values.
[CCS8.0.0.00016 on Windows 7 64bit]
It looks like this:
class A
{
public:
virtual ~A(){};
protected:
A() :
a(0),
b(0),
c(0),
d(0)
{};
private:
int a;
int b;
int c;
int d;
};
class B : public virtual A
{
public:
virtual ~B(){};
protected:
B(){};
};
class C : public virtual A
{
public:
virtual ~C(){};
protected:
C(){};
};
class D : public B, public C
{
public:
D(){};
virtual ~D(){};
};
Walking through each of the constructors with the debugger the values are clearly initialised in the base class attributes to 0 but as I move up to each of the inheriting constructors each of the inheriting classes has its own addresses for the attributes which have moved slightly. the last two attributes (c & d) are referencing the top two (a & b) while a & b appear to be referencing the vtable!
Any ideas?
Thanks in advance.
Andy.