1
0
mirror of https://github.com/golang/go synced 2024-11-17 22:34:47 -07:00
go/test/fixedbugs/issue22458.go
Keith Randall 0153a4130d cmd/compile: fix runtime.KeepAlive
KeepAlive needs to introduce a use of the spill of the
value it is keeping alive.  Without that, we don't guarantee
that the spill dominates the KeepAlive.

This bug was probably introduced with the code to move spills
down to the dominator of the restores, instead of always spilling
just after the value itself (CL 34822).

Fixes #22458.

Change-Id: I94955a21960448ffdacc4df775fe1213967b1d4c
Reviewed-on: https://go-review.googlesource.com/74210
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
2017-10-30 19:55:02 +00:00

27 lines
456 B
Go

// compile
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Make sure KeepAlive introduces a use of the spilled variable.
package main
import "runtime"
type node struct {
next *node
}
var x bool
func main() {
var head *node
for x {
head = &node{head}
}
runtime.KeepAlive(head)
}