modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/fixedbugs/issue20250.go (about) 1 // errorcheck -0 -live -l -d=compilelater,eagerwb 2 3 // Copyright 2017 The Go Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 // Issue 20250: liveness differed with concurrent compilation 8 // due to propagation of addrtaken to outer variables for 9 // closure variables. 10 11 // TODO(austin): This expects function calls to the write barrier, so 12 // we enable the legacy eager write barrier. Fix this once the 13 // buffered write barrier works on all arches. 14 15 package p 16 17 type T struct { 18 s string 19 } 20 21 func f(a T) { // ERROR "live at entry to f: a" 22 var e interface{} 23 func() { // ERROR "live at entry to f.func1: a &e" 24 e = a.s // ERROR "live at call to convT2Estring: a &e" "live at call to writebarrierptr: a" 25 }() // ERROR "live at call to f.func1: e$" 26 // Before the fix, both a and e were live at the previous line. 27 _ = e 28 }