[Bug go/64021] New: Empty struct vs libffi
rth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Nov 22 08:51:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64021
Bug ID: 64021
Summary: Empty struct vs libffi
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: go
Assignee: ian at airs dot com
Reporter: rth at gcc dot gnu.org
CC: cmang at google dot com
In go_struct_to_ffi, an empty struct is maped to ffi_type_void.
On i386, some ABIs return a struct pop 4 bytes of stack. If one
calls a function returning a structure without preparing for this,
the stack will be corrupted.
On sparc32, functions returning a structure return to a different
address. If one calls a function returning a structure without
preparing for this, the instruction after the call will be skipped.
In both cases, this causes reflect/all_test.go returnEmpty to fail.
I wonder what's better: follow C++ and map empty structures to a
single byte (i.e. no more zero-sized structures), or enhance libffi
to be able to deal with empty structures so that we don't have to
lie to libffi about the type being manipulated?
More information about the Gcc-bugs
mailing list