From: Ian Lance Taylor Date: Fri, 1 Apr 2022 03:41:12 +0000 (-0700) Subject: unsafe: document that Sizeof includes field alignment X-Git-Tag: go1.19beta1~772 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=11ec59a60e0d18e805b7f0c3a2c5ee8c10481877;p=gostls13.git unsafe: document that Sizeof includes field alignment Fixes #52018 Change-Id: I6d06d5b5279b9bdc899b0ad43488577d3c0b94be Reviewed-on: https://go-review.googlesource.com/c/go/+/397516 Trust: Ian Lance Taylor Reviewed-by: Emmanuel Odeke Reviewed-by: Rob Pike --- diff --git a/src/unsafe/unsafe.go b/src/unsafe/unsafe.go index 4a3d7feda7..ae69dea4af 100644 --- a/src/unsafe/unsafe.go +++ b/src/unsafe/unsafe.go @@ -187,6 +187,7 @@ type Pointer *ArbitraryType // The size does not include any memory possibly referenced by x. // For instance, if x is a slice, Sizeof returns the size of the slice // descriptor, not the size of the memory referenced by the slice. +// For a struct, the size includes any padding introduced by field alignment. // The return value of Sizeof is a Go constant. func Sizeof(x ArbitraryType) uintptr