From: Jay Freeman (saurik) Date: Wed, 30 Dec 2015 04:15:00 +0000 (-0800) Subject: Add workaround for zero-sized struct (and use it). X-Git-Tag: v0.9.590~119 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/255fe37ec14bde323d6526abd43136ba2b1c9903?ds=sidebyside Add workaround for zero-sized struct (and use it). --- diff --git a/Analyze.cpp b/Analyze.cpp index 1eac8a0..b98e027 100644 --- a/Analyze.cpp +++ b/Analyze.cpp @@ -127,6 +127,8 @@ std::ostream &operator <<(std::ostream &out, const CYCXPositionalignment = 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; }