From 255fe37ec14bde323d6526abd43136ba2b1c9903 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 29 Dec 2015 20:15:00 -0800 Subject: [PATCH] Add workaround for zero-sized struct (and use it). --- Analyze.cpp | 14 ++++++++++---- sig/ffi_type.cpp | 15 +++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) 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; } -- 2.45.2