modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/fixedbugs/issue7997.go (about)

     1  // compile
     2  
     3  // Copyright 2014 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  // /tmp/x.go:3: internal error: f &p (type *int) recorded as live on entry
     8  
     9  package p
    10  
    11  func f(ch chan int) *int {
    12  	select {
    13  	case p1x := <-ch:
    14  		return &p1x
    15  	default:
    16  		// ok
    17  	}
    18  	select {
    19  	case p1 := <-ch:
    20  		return &p1
    21  	default:
    22  		// ok
    23  	}
    24  	select {
    25  	case p2 := <-ch:
    26  		return &p2
    27  	case p3 := <-ch:
    28  		return &p3
    29  	default:
    30  		// ok
    31  	}
    32  	select {
    33  	case p4, ok := <-ch:
    34  		if ok {
    35  			return &p4
    36  		}
    37  	default:
    38  		// ok
    39  	}
    40  	select {
    41  	case p5, ok := <-ch:
    42  		if ok {
    43  			return &p5
    44  		}
    45  	case p6, ok := <-ch:
    46  		if !ok {
    47  			return &p6
    48  		}
    49  	default:
    50  		// ok
    51  	}
    52  	return nil
    53  }