re PR go/68496 ([libgo] reflect test fails on Linux x86-64)
authorIan Lance Taylor <ian@gcc.gnu.org>
Mon, 23 Nov 2015 21:17:45 +0000 (21:17 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Mon, 23 Nov 2015 21:17:45 +0000 (21:17 +0000)
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

gcc/go/gofrontend/MERGE
libgo/runtime/go-reflect-call.c

index 9ee3535a4f7be4f947ae2b0f2803b029e49ce5ec..9fe9d5e1042de9814624164490cfc75ab880309b 100644 (file)
@@ -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 29e814a793f6e8fb0c898b073009db80a8605f7b..2a14d6c6adddebdd79a80738abe417f2bc836b2a 100644 (file)
@@ -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;
 }