[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
An memory layout issue in g++
From: |
孙朝阳 |
Subject: |
An memory layout issue in g++ |
Date: |
Sun, 16 Sep 2012 18:44:12 -0700 (PDT) |
User-agent: |
G2/1.0 |
I searched the ABI description in
http://mentorembedded.github.com/cxx-abi/cxx-vtable-ex.html &
http://www.phpcompiler.org/articles/virtualinheritance.html, and didn't found
the exactly description for the following case:
struct Foo{ virtual void foo() {} };
struct Bar{ virtual void bar() {} };
struct B { void* data; };
struct X : public B, Foo, Bar { };
I expected the memory order of bases is:
{
data of B;
vptr of Foo;
vptr of Bar;
}
but the actual result is:
{
vptr of Foo;
data of B;
vptr of Bar;
};
if both Foo and Bar has no virtual functions, the result would be:
{
data of B;
vptr of Foo;
vptr of Bar;
};
So, I can't judge the memory layout for the following code:
template<typename A, typename B, typename C>
struct Mix : public A, B, C {}
So, I want to know, is it a bug of gcc? Is the case clarified in any standards?
Great thanks for any information.
- An memory layout issue in g++,
孙朝阳 <=