# HG changeset patch # User Tomas Lindquist Olsen # Date 1241923023 -7200 # Node ID 459b6b6f9a8d9301952d4c893e35fb1bdd3d6d29 # Parent e5b57fd8307cabd4333878f78b197cf1f768c348 Fixed D-style vararg arguments with types that have sizes bigger that pointers, yet are not aligned to pointer sizes. Fixes ticket #276 . diff -r e5b57fd8307c -r 459b6b6f9a8d gen/tocall.cpp --- a/gen/tocall.cpp Sun May 10 04:18:14 2009 +0200 +++ b/gen/tocall.cpp Sun May 10 04:37:03 2009 +0200 @@ -141,8 +141,28 @@ assert(argexp->type->ty != Ttuple); vtypes.push_back(DtoType(argexp->type)); size_t sz = getTypePaddedSize(vtypes.back()); - if (sz < PTRSIZE) - vtypes.back() = DtoSize_t(); + size_t asz = (sz + PTRSIZE - 1) & ~(PTRSIZE -1); + if (sz != asz) + { + if (sz < PTRSIZE) + { + vtypes.back() = DtoSize_t(); + } + else + { + // ok then... so we build some type that is big enough + // and aligned to PTRSIZE + std::vector gah; + gah.reserve(asz/PTRSIZE); + size_t gah_sz = 0; + while (gah_sz < asz) + { + gah.push_back(DtoSize_t()); + gah_sz += PTRSIZE; + } + vtypes.back() = LLStructType::get(gah, true); + } + } } const LLStructType* vtype = LLStructType::get(vtypes);