initial commit

This commit is contained in:
2025-08-27 08:48:19 -04:00
commit 85bac6b12b
25 changed files with 570 additions and 0 deletions

18
sizeofstring/step3.go Normal file
View File

@@ -0,0 +1,18 @@
package bocchi
import "unsafe"
type Bocchi struct {
x uint32
y uint64
}
// step3.go
var (
// assert Bocchi.x doesn't move
_ [0]struct{} = [unsafe.Offsetof(Bocchi{}.x) - 0]struct{}{}
// assert Bocchi.y comes next after Bocchi.x
_ [0]struct{} = [unsafe.Offsetof(Bocchi{}.y) - (unsafe.Alignof(Bocchi{}.y))]struct{}{}
// assert y is the last field in Bocchi
_ [0]struct{} = [unsafe.Sizeof(Bocchi{}) - (unsafe.Alignof(Bocchi{}.y) + unsafe.Sizeof(Bocchi{}.y))]struct{}{}
)