Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/types: miscalculation of unsafe.Sizeof #60652

wdvxdr1123 opened this issue Jun 7, 2023 · 2 comments

go/types: miscalculation of unsafe.Sizeof #60652

wdvxdr1123 opened this issue Jun 7, 2023 · 2 comments


Copy link

What version of Go are you using (go version)?

$ go version
go version go1.20.1 darwin/amd64

Does this issue reproduce with the latest release?


What did you do?

package main

import "unsafe"

type foo struct {
	a int64
	b bool

func main() {
	var _ [unsafe.Sizeof(foo{}) - 16]byte

This program compiles ok and can print 16 on amd64. However, go vet reports
vet: ./prog.go:11:9: unsafe.Sizeof(foo{}) - 16 (constant -7 of type uintptr) overflows uintptr.
This may be due to a miscalculation of unsafe.Sizeof(foo{}) by go/types packages.
cc @griesemer

Copy link

Change mentions this issue: go/types: fix calc sizeof struct type

Copy link

cuonglm commented Jun 7, 2023

Duplicated of #60431

@cuonglm cuonglm closed this as completed Jun 7, 2023
@golang golang locked and limited conversation to collaborators Jun 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

3 participants