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, cmd/compile: disagreement on struct field offset on amd64p32 #16464

Closed
josharian opened this issue Jul 22, 2016 · 6 comments
Closed
Milestone

Comments

@josharian
Copy link
Contributor

The compiler and go/types disagree about the offset of y in

var s struct {
    x *int
    y []byte
}

on amd64p32. I am using sizes types.StdSizes{WordSize: 4, MaxAlign: 8}. The compiler says y's offset is 4; go/types says it is 8. I think the compiler is right, insofar as code relying on this runs and works on nacl.

https://play.golang.org/p/VbR2IIeyUt calculates and displays the offsets of x and y via unsafe and via go/types. Since the playground runs amd64p32, you can see the results directly by hitting Run. I also confirmed with nacl/amd64p32 locally.

Found while working on #11041. I'm happy to look into a fix, but I'd like confirmation first that the correct answer is 4.

cc @griesemer

@randall77
Copy link
Contributor

4 sounds like the correct answer to me.

@minux
Copy link
Member

minux commented Jul 22, 2016 via email

@quentinmit quentinmit added this to the Go1.8 milestone Jul 29, 2016
@josharian josharian self-assigned this Aug 7, 2016
@griesemer
Copy link
Contributor

I'll take this.

@griesemer griesemer self-assigned this Aug 12, 2016
@josharian
Copy link
Contributor Author

I have a working CL already. Just haven't had time to mail it yet.

@gopherbot
Copy link

CL https://golang.org/cl/26991 mentions this issue.

@gopherbot
Copy link

CL https://golang.org/cl/26996 mentions this issue.

@griesemer griesemer removed their assignment Aug 15, 2016
@golang golang locked and limited conversation to collaborators Aug 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants