...

Source file src/cmd/compile/internal/ssa/testdata/i22558.go

Documentation: cmd/compile/internal/ssa/testdata

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  )
     7  
     8  type big struct {
     9  	pile [768]int8
    10  }
    11  
    12  type thing struct {
    13  	name  string
    14  	next  *thing
    15  	self  *thing
    16  	stuff []big
    17  }
    18  
    19  func test(t *thing, u *thing) {
    20  	if t.next != nil {
    21  		return
    22  	}
    23  	fmt.Fprintf(os.Stderr, "%s\n", t.name)
    24  	u.self = u
    25  	t.self = t
    26  	t.next = u
    27  	for _, p := range t.stuff {
    28  		if isFoo(t, p) {
    29  			return
    30  		}
    31  	}
    32  }
    33  
    34  //go:noinline
    35  func isFoo(t *thing, b big) bool {
    36  	return true
    37  }
    38  
    39  func main() {
    40  	growstack() // Use stack early to prevent growth during test, which confuses gdb
    41  	t := &thing{name: "t", self: nil, next: nil, stuff: make([]big, 1)}
    42  	u := thing{name: "u", self: t, next: t, stuff: make([]big, 1)}
    43  	test(t, &u)
    44  }
    45  
    46  var snk string
    47  
    48  //go:noinline
    49  func growstack() {
    50  	snk = fmt.Sprintf("%#v,%#v,%#v", 1, true, "cat")
    51  }
    52  

View as plain text