On Fri, Aug 04, 2017 at 02:25:01AM -0700, 樊冰心 wrote:

[...]
> type T struct {
> i int
> x struct{}
> }
> 
> func main() {
> var t T
> fmt.Println(unsafe.Sizeof(t))
> }
> 
> Since size of struct{} is 0, why the result is 16?

Consider also reading
https://dave.cheney.net/2014/03/25/the-empty-struct
and
https://dave.cheney.net/2015/10/09/padding-is-hard

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to