public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug go/64021] New: Empty struct vs libffi
@ 2014-11-22  8:51 rth at gcc dot gnu.org
  2014-11-22  8:55 ` [Bug go/64021] " rth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: rth at gcc dot gnu.org @ 2014-11-22  8:51 UTC (permalink / raw)
  To: gcc-bugs

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?


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-11-24 15:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-22  8:51 [Bug go/64021] New: Empty struct vs libffi rth at gcc dot gnu.org
2014-11-22  8:55 ` [Bug go/64021] " rth at gcc dot gnu.org
2014-11-22 13:09 ` hjl.tools at gmail dot com
2014-11-22 21:56 ` pinskia at gcc dot gnu.org
2014-11-24  7:48 ` rth at gcc dot gnu.org
2014-11-24  9:16 ` jakub at gcc dot gnu.org
2014-11-24  9:58 ` rth at gcc dot gnu.org
2014-11-24 15:40 ` ian at airs dot com
2014-11-24 15:45 ` rth at gcc dot gnu.org

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).