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

go/types, cmd/compile: disagreement on struct field offset on amd64p32 #16464

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

Comments

@josharian
Copy link
Contributor

@josharian josharian commented Jul 22, 2016

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

@randall77 randall77 commented Jul 22, 2016

4 sounds like the correct answer to me.

Loading

@minux
Copy link
Member

@minux minux commented Jul 22, 2016

Loading

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

@griesemer griesemer commented Aug 12, 2016

I'll take this.

Loading

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

@josharian josharian commented Aug 12, 2016

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

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 13, 2016

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

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 13, 2016

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

Loading

@griesemer griesemer removed their assignment Aug 15, 2016
@gopherbot gopherbot closed this in e0d8064 Aug 16, 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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants