Source file test/fixedbugs/issue26105.go

     1  // compile
     2  
     3  // Copyright 2018 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  // Triggers a bug in writebarrier, which inserts one
     8  // between (first block) OpAddr x and (second block) a VarDef x,
     9  // which are then in the wrong order and unable to be
    10  // properly scheduled.
    11  
    12  package q
    13  
    14  var S interface{}
    15  
    16  func F(n int) {
    17  	fun := func(x int) int {
    18  		S = 1
    19  		return n
    20  	}
    21  	i := fun(([]int{})[n])
    22  
    23  	var fc [2]chan int
    24  	S = (([1][2]chan int{fc})[i][i])
    25  }
    26  

View as plain text