mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/gc: resolve static addresses of the form &x.f at link time
When we do y = &x for global variables x and y, y gets initialized at link time. Do the same for y = &x.f if x is a struct and y=&x[5] if x is an array. fixes #9217 fixes #9355 Change-Id: Iea3c0ce2ce1b309e2b760e345608fd95460b5713 Reviewed-on: https://go-review.googlesource.com/1691 Reviewed-by: Minux Ma <minux@golang.org>
This commit is contained in:
parent
340ef004d6
commit
2fc29a83ae
3 changed files with 72 additions and 8 deletions
16
test/fixedbugs/issue9355.dir/a.go
Normal file
16
test/fixedbugs/issue9355.dir/a.go
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package main
|
||||
|
||||
var x struct {
|
||||
a, b, c int64
|
||||
d struct{ p, q, r int32 }
|
||||
e [8]byte
|
||||
f [4]struct{ p, q, r int32 }
|
||||
}
|
||||
|
||||
var y = &x.b
|
||||
var z = &x.d.q
|
||||
|
||||
var b [10]byte
|
||||
var c = &b[5]
|
||||
|
||||
var w = &x.f[3].r
|
||||
Loading…
Add table
Add a link
Reference in a new issue