aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime/go-reflect-call.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2015-11-23 21:17:45 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2015-11-23 21:17:45 +0000
commit8c61286797664f445db424050ea4c73cf265b242 (patch)
treed37869769756562cc2596cd4783de2c387baf6b9 /libgo/runtime/go-reflect-call.c
parentcbd03aee24f57b42a82a119e4182b442ef3b8db3 (diff)
downloadgcc-8c61286797664f445db424050ea4c73cf265b242.zip
gcc-8c61286797664f445db424050ea4c73cf265b242.tar.gz
gcc-8c61286797664f445db424050ea4c73cf265b242.tar.bz2
re PR go/68496 ([libgo] reflect test fails on Linux x86-64)
PR go/68496 reflect: Allocate space for FFI functions returning a zero-sized type. The libffi library does not understand zero-sized types. We represent them as a struct with a single field of type void. If such a type is returned from a function, libffi will copy 1 byte of data. Allocate space for that byte, although we won't use it. Fixes https://gcc.gnu.org/PR68496. Reviewed-on: https://go-review.googlesource.com/17175 From-SVN: r230776
Diffstat (limited to 'libgo/runtime/go-reflect-call.c')
-rw-r--r--libgo/runtime/go-reflect-call.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libgo/runtime/go-reflect-call.c b/libgo/runtime/go-reflect-call.c
index 29e814a..2a14d6c 100644
--- a/libgo/runtime/go-reflect-call.c
+++ b/libgo/runtime/go-reflect-call.c
@@ -81,6 +81,12 @@ go_results_size (const struct __go_func_type *func)
off = (off + maxalign - 1) & ~ (maxalign - 1);
+ // The libffi library doesn't understand a struct with no fields.
+ // We generate a struct with a single field of type void. When used
+ // as a return value, libffi will think that requires a byte.
+ if (off == 0)
+ off = 1;
+
return off;
}