| Server IP : 217.160.0.212 / Your IP : 216.73.216.141 Web Server : Apache System : Linux www 6.18.51-i1-ampere #1196 SMP Fri Sep 11 20:43:55 CEST 2026 aarch64 User : sws1073854427 ( 1073854427) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /usr/lib/go-1.23/test/fixedbugs/ |
Upload File : |
// run
// Copyright 2019 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.
// Issue 30977: write barrier call clobbers volatile
// value when there are multiple uses of the value.
package main
import "runtime"
type T struct {
a, b, c, d, e string
}
//go:noinline
func g() T {
return T{"a", "b", "c", "d", "e"}
}
//go:noinline
func f() {
// The compiler optimizes this to direct copying
// the call result to both globals, with write
// barriers. The first write barrier call clobbers
// the result of g on stack.
X = g()
Y = X
}
var X, Y T
const N = 1000
func main() {
// Keep GC running so the write barrier is on.
go func() {
for {
runtime.GC()
}
}()
for i := 0; i < N; i++ {
runtime.Gosched()
f()
if X != Y {
panic("FAIL")
}
}
}