This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

libgo patch committed: treat functions that return zero bytes as returning void


PR 72814 is a bug that is due to a mismatch between libffi and the
code being called when the code returns a zero-sized struct.  libffi
can not represent a zero-sized struct, so the Go runtime creates a
libffi type that uses a one-byte struct.  This technique fails on
32-bit SPARC, where the calling convention for a zero-sized struct is
different than the calling convention for a one-byte struct; calls to
the latter function are followed by an unimp instruction, calls to the
former are not.

This patch fixes the problem by treating functions that return zero
result byte as though they actually return void.  The change is to the
GCC interface and the libffi interface used by the gofrontend.

For this patch bootstrapped on x86_64-pc-linux-gnu and
sparc-sun-solaris.  Ran the full Go testsuite on x86_64-pc-linux-gnu
and the reflect package tests on sparc-sun-solaris.  Committed to
mainline.

Ian

2016-08-08  Ian Lance Taylor  <iant@google.com>

PR go/72814
* go-gcc.cc (Gcc_backend::function_type): If the return type is
zero bytes, treat the function as returning void.
(return_statement): If the return type is zero bytes, don't
actually return any values.

Attachment: patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]