[cfe-dev] Struct init codegen and padding

Eli Friedman eli.friedman at gmail.com
Fri Jan 25 09:49:09 PST 2008


On Jan 24, 2008 8:09 PM, Sanghyeon Seo <sanxiyn at gmail.com> wrote:
> This test program crashes in CodeGen.
> struct s { short a; int b; } x = {1, 1};
>
> "struct s" converts to LLVM type {i16, i8, i8, i32}, padded with i8.
> CodeGen attempts llvm::ConstantStruct::get({i16, i8, i8, i32}, {1, 1})
> and crashes, since the type has 4 elements but initializer has only 2.

Here's a fix.  It doesn't completely implement struct initializer
codegen, but it's enough to codegen all fully braced initializers that
don't initialize bitfields.

-Eli
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: structinitcodegen.txt
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080125/c8baf5c0/attachment.txt>


More information about the cfe-dev mailing list