From 2f1c768885116676fbf6188c7a4b41ac3bd382cb Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 8 Oct 2014 13:49:38 -0700 Subject: [PATCH] go/types: document default unsafe.Sizeof computation better LGTM=adonovan R=adonovan CC=golang-codereviews https://golang.org/cl/155150043 --- go/types/sizes.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/go/types/sizes.go b/go/types/sizes.go index fe24345d4ec..cb911bbf91f 100644 --- a/go/types/sizes.go +++ b/go/types/sizes.go @@ -28,6 +28,11 @@ type Sizes interface { // specified size. // - The size of strings and interfaces is 2*WordSize. // - The size of slices is 3*WordSize. +// - The size of arrays is the aligned size (see below) of an element +// multiplied by the number of elements. +// - The size of a struct is the offset of the last field plus that +// field's size. If the struct is used in an array its size must +// first be aligned to a multiple of the struct's alignment. // - All other types have size WordSize. // - Arrays and structs are aligned per spec definition; all other // types are naturally aligned with a maximum alignment MaxAlign.