PR 68496 points out a bug in the handling of reflect.Call calling a
function that returns a zero-sized type.  libffi doesn't understand
zero-sized types, which don't exist in C, so they require special
handling.  This patch fixes the problem.  Bootstrapped and ran Go
testsuite on x86_64-pc-linux-gnu.  Committed to mainline and GCC 5
branch.

Ian
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE     (revision 230759)
+++ gcc/go/gofrontend/MERGE     (working copy)
@@ -1,4 +1,4 @@
-97ec885c715b3922b0866c081554899b8d50933a
+0d979f0b860cfd879754150e0ae5e1018b94d7c4
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/runtime/go-reflect-call.c
===================================================================
--- libgo/runtime/go-reflect-call.c     (revision 230759)
+++ libgo/runtime/go-reflect-call.c     (working copy)
@@ -81,6 +81,12 @@ go_results_size (const struct __go_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;
 }
 

Reply via email to