This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Different Object Model in g++-2.95 and g++-3.3.5?


Hi, all:

I compiled the following code using g++-2.95:
---------------------------------------------------------------------
#include <iostream>
using namespace std;

class A {
public:
    virtual void echo () {};
};

class B: public virtual A {
public:
    int b;
    virtual void echo () {};
};

int
main()
{
    cout << sizeof(A) << endl;
    cout << sizeof(B) << endl;

    return 0;
}
--------------------------------------------------------------------
The result is:
4
12


If I compile it using g++-3.3.5, the result is:
4
8

So I am wondering whether g++-3.3.5 changes its object model.



-------------------
Holderlin Zhang
Department of Applied Math., Nankai University


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]