Spockwang's Blog

The G++ Implementation of C++ Object Model

| 评论

This text discusses the C++ object model implemented by g++, including the memory layout of C++ objects and implementation mechanism of polymorphism, virtual inheritance, pointer to data member and member function and RTTI. I have never seen any official document on these issues. As far as I know Inside the C++ object model by Stanley Lippman is the only book which has detailed descriptions on the underlying mechanism. Unfortunately the materials in that book are mostly about some very old C++ compilers which are rarely used today. But it is a great help for me to study the details about g++.

The mechanisms are studied by disassembling the object code generated by g++ so I can not guarantee it is correct. All examples are tested under g++ 4.4.3 and Ubuntu 10.04.