https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64021

--- Comment #7 from Ian Lance Taylor <ian at airs dot com> ---
The Go language says that "Pointers to distinct zero-size variables may or may
not be equal" (http://golang.org/ref/spec#Comparison_operators).  So in the
language sense it would be OK to always convert zero-sized structs to contain a
single byte.  Go programmers routinely write things like make(chan struct{},
1000) and expect the channel to not take any space--the channel will keep a
count of elements but the element storage won't take any space; however, I
think that would continue to work as expected, since the libgo code looks at
the size in the Go type descriptor, which would continue to be zero.

I think the cleanest approach would be to modify libffi.  But as far as I can
always representing zero-sized structs as 1 byte in GIMPLE would work.  It
would mean we could remove Gcc_backend::non_zero_size_type.

I note that a zero-sized array is converted to an empty struct in go-ffi.c.  I
wonder how libffi handles that today.

Reply via email to