public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* libgo patch committed: Fix reflect.Call of function returning zero-sized type
@ 2015-11-23 21:56 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2015-11-23 21:56 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 348 bytes --]

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

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 990 bytes --]

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;
 }
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-11-23 21:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-23 21:56 libgo patch committed: Fix reflect.Call of function returning zero-sized type Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).