> If you're saying that: > > >> %I = type { i32, i8 }; >> > has size 5, yes, you're missing the alignment. >Ah, now I see. But I didn't say that %I = type { i32, i8 }; has 5 bytes (because it has 8) but I thought that it has 5 bytes when being a member of %J, i.e. %J = type { %I, i8 } In this case %I also has 8 bytes right? I was thinking too much in terms of C++ inheritance. Then perhaps the tailpadding should be specified explicitly ;-) %I = type { i32, i8 }; // 5 bytes %I' = type { %I, tailpad}; // 8 bytes %J = type { %I, i8 } // 6 bytes -Jochen
On 24 February 2011 16:27, Jochen Wilhelmy <j.wilhelmy at arcor.de> wrote:> %I = type { i32, i8 }; // 5 bytes > %I' = type { %I, tailpad}; // 8 bytes > %J = type { %I, i8 } // 6 bytesThat would break C code (and whatever else relies on alignment). I don't see a way of specifying two structures, but I like the idea of using a packed structure for inheritance and the "normal" one for types. cheers, --renato
>> %I = type { i32, i8 }; // 5 bytes >> %I' = type { %I, tailpad}; // 8 bytes >> %J = type { %I, i8 } // 6 bytes >> > That would break C code (and whatever else relies on alignment). >why would it break C code? of course a C frontend should generate only tailpadded types.> I don't see a way of specifying two structures, but I like the idea of > using a packed structure for inheritance and the "normal" one for > types. >or something like %J = type { inherit %I, i8 } the inherit keyword before %I removes the tailpadding -Jochen