Debian Codegraph @

gcc/testsuite/go.test/test/fixedbugs/issue25897b.go

raw
1 // run
2
3 // Copyright 2019 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 // Make sure the runtime can scan args of an unstarted goroutine
8 // which starts with a reflect-generated function.
9
10 package main
11
12 import (
13 "reflect"
14 "runtime"
15 )
16
17 const N = 100
18
19 type T struct {
20 }
21
22 func (t *T) Foo(c chan bool) {
23 c <- true
24 }
25
26 func main() {
27 t := &T{}
28 runtime.GOMAXPROCS(1)
29 c := make(chan bool, N)
30 for i := 0; i < N; i++ {
31 f := reflect.ValueOf(t).MethodByName("Foo").Interface().(func(chan bool))
32 go f(c)
33 }
34 runtime.GC()
35 for i := 0; i < N; i++ {
36 <-c
37 }
38 }