Source file test/fixedbugs/issue49282.go

     1  // compile
     2  
     3  // Copyright 2021 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  package p
     8  
     9  //go:noinline
    10  func g(d uintptr, a, m []int, s struct {
    11  	a, b, c, d, e int
    12  }, u uint) {
    13  	_ = a
    14  	_ = m
    15  	_ = s
    16  	func() {
    17  		for i := 0; i < 5; i++ {
    18  			_ = a
    19  			_ = m
    20  			_, _ = s, s
    21  		}
    22  	}()
    23  }
    24  
    25  var One float64 = 1.0
    26  
    27  func f(d uintptr) {
    28  	var a, m []int
    29  	var s struct {
    30  		a, b, c, d, e int
    31  	}
    32  
    33  	g(d, a, m, s, uint(One)) // Uint of not-a-constant inserts a conditional, necessary to bug
    34  
    35  	defer func() uint {
    36  		return 0
    37  	}()
    38  }
    39  
    40  var d uintptr
    41  
    42  func h() {
    43  	f(d)
    44  }
    45  

View as plain text