[LLVMdev] Object layout bug for C++ derived class with long long integer

Anton Korobeynikov anton at korobeynikov.info
Sat Feb 27 04:33:35 PST 2010


Hello, Christophe

> I have a simple C++ class that looks like this:
>
>        struct Foo { Thing *first; Blob *second; unsigned long third; };
>
> Then I have a derived C++ class that look like this:
>
>        struct Bar : Foo { long long fourth; }
How does the generated LLVM IR for these structs look like?

> This is wrong compared to the native layout of the C++ object.
What is the "native layout of the C++ object"? How is it defined?

> The compiler inserts some padding in Foo between third (32-bit) and fourth (64-bit), presumably for alignment reasons.
Which compiler? llvm-gcc tries to follow the mainline gcc for mingw
platform. There were some changes post-2.6 wrt long long native
alignment, you might try to look into code at svn head.

-- 
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University



More information about the llvm-dev mailing list