Debian Codegraph @

gcc/testsuite/go.test/test/fixedbugs/issue25897a.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 func main() {
20 runtime.GOMAXPROCS(1)
21 c := make(chan bool, N)
22 for i := 0; i < N; i++ {
23 f := reflect.MakeFunc(reflect.TypeOf(((func(*int))(nil))),
24 func(args []reflect.Value) []reflect.Value {
25 c <- true
26 return nil
27 }).Interface().(func(*int))
28 go f(nil)
29 }
30 runtime.GC()
31 for i := 0; i < N; i++ {
32 <-c
33 }
34 }