X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/574d47203e63ac4a85f0d609098118d19e6bbf09..7341eedbaf526ef2f0986b576c656906050e270a:/sig/ffi_type.cpp diff --git a/sig/ffi_type.cpp b/sig/ffi_type.cpp index e114db8..5d31b0f 100644 --- a/sig/ffi_type.cpp +++ b/sig/ffi_type.cpp @@ -1,5 +1,5 @@ -/* Cycript - Optimizing JavaScript Compiler/Runtime - * Copyright (C) 2009-2015 Jay Freeman (saurik) +/* Cycript - The Truly Universal Scripting Language + * Copyright (C) 2009-2016 Jay Freeman (saurik) */ /* GNU Affero General Public License, Version 3 {{{ */ @@ -158,10 +158,17 @@ ffi_type *Aggregate::GetFFI(CYPool &pool) const { ffi->alignment = 0; ffi->type = FFI_TYPE_STRUCT; - ffi->elements = new(pool) ffi_type *[signature.count + 1]; - for (size_t index(0); index != signature.count; ++index) - ffi->elements[index] = signature.elements[index].type->GetFFI(pool); - ffi->elements[signature.count] = NULL; + if (signature.count == 0) { + // https://gcc.gnu.org/ml/gcc-patches/2015-01/msg01286.html + ffi->elements = new(pool) ffi_type *[2]; + ffi->elements[0] = &ffi_type_void; + ffi->elements[1] = NULL; + } else { + ffi->elements = new(pool) ffi_type *[signature.count + 1]; + for (size_t index(0); index != signature.count; ++index) + ffi->elements[index] = signature.elements[index].type->GetFFI(pool); + ffi->elements[signature.count] = NULL; + } return ffi; }