Source file test/fixedbugs/issue75569.go

     1  // run
     2  
     3  // Copyright 2025 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 main
     8  
     9  func fff(a []int, b bool, p, q *int) {
    10  outer:
    11  	n := a[0]
    12  	a = a[1:]
    13  	switch n {
    14  	case 1:
    15  		goto one
    16  	case 2:
    17  		goto two
    18  	case 3:
    19  		goto three
    20  	case 4:
    21  		goto four
    22  	}
    23  
    24  one:
    25  	goto inner
    26  two:
    27  	goto outer
    28  three:
    29  	goto inner
    30  four:
    31  	goto innerSideEntry
    32  
    33  inner:
    34  	n = a[0]
    35  	a = a[1:]
    36  	switch n {
    37  	case 1:
    38  		goto outer
    39  	case 2:
    40  		goto inner
    41  	case 3:
    42  		goto innerSideEntry
    43  	default:
    44  		return
    45  	}
    46  innerSideEntry:
    47  	n = a[0]
    48  	a = a[1:]
    49  	switch n {
    50  	case 1:
    51  		goto outer
    52  	case 2:
    53  		goto inner
    54  	case 3:
    55  		goto inner
    56  	}
    57  	ggg(p, q)
    58  	goto inner
    59  }
    60  
    61  var b bool
    62  
    63  func ggg(p, q *int) {
    64  	n := *p + 5 // this +5 ends up in the entry block, well before the *p load
    65  	if b {
    66  		*q = 0
    67  	}
    68  	*p = n
    69  }
    70  
    71  func main() {
    72  	var x, y int
    73  	fff([]int{4, 4, 4}, false, &x, &y)
    74  	if x != 5 {
    75  		panic(x)
    76  	}
    77  }
    78  

View as plain text