Source file test/fixedbugs/issue20250.go

     1  // errorcheck -0 -live -l
     2  
     3  //go:build !goexperiment.cgocheck2
     4  
     5  // Copyright 2017 The Go Authors. All rights reserved.
     6  // Use of this source code is governed by a BSD-style
     7  // license that can be found in the LICENSE file.
     8  
     9  // Issue 20250: liveness differed with concurrent compilation
    10  // due to propagation of addrtaken to outer variables for
    11  // closure variables.
    12  
    13  package p
    14  
    15  type T struct {
    16  	s [2]string
    17  }
    18  
    19  func f(a T) { // ERROR "live at entry to f: a$"
    20  	var e interface{} // ERROR "stack object e interface \{\}$"
    21  	func() {          // ERROR "live at entry to f.func1: &e a$"
    22  		e = a.s // ERROR "live at call to convT: &e$" "stack object a T$"
    23  	}()
    24  	// Before the fix, both a and e were live at the previous line.
    25  	_ = e
    26  }
    27  

View as plain text