]> Cypherpunks repositories - gostls13.git/commitdiff
unsafe: document that Sizeof includes field alignment
authorIan Lance Taylor <iant@golang.org>
Fri, 1 Apr 2022 03:41:12 +0000 (20:41 -0700)
committerIan Lance Taylor <iant@golang.org>
Mon, 4 Apr 2022 20:37:59 +0000 (20:37 +0000)
Fixes #52018

Change-Id: I6d06d5b5279b9bdc899b0ad43488577d3c0b94be
Reviewed-on: https://go-review.googlesource.com/c/go/+/397516
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Rob Pike <r@golang.org>
src/unsafe/unsafe.go

index 4a3d7feda73642dbfbd41b7d77e51e8c27b59d8b..ae69dea4af7948c965137069265ab52d2a8783ec 100644 (file)
@@ -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