FooI(a,b,c)// ERROR "a escapes to heap" "b escapes to heap" "c escapes to heap" "TFooI ... argument does not escape"
}
funcFooJ(args...interface{})*int32{// ERROR "leaking param: args to result ~r1 level=1"
fori:=0;i<len(args);i++{
switchx:=args[i].(type){
casenil:
println("is nil")
caseint32:
println("is int32")
case*int32:
println("is *int32")
returnx
casestring:
println("is string")
}
}
returnnil
}
funcTFooJ1(){
a:=int32(1)
b:="cat"
c:=&a// ERROR "TFooJ1 &a does not escape"
FooJ(a,b,c)// ERROR "TFooJ1 a does not escape" "TFooJ1 b does not escape" "TFooJ1 c does not escape" "TFooJ1 ... argument does not escape"
}
funcTFooJ2(){
a:=int32(1)// ERROR "moved to heap: a"
b:="cat"
c:=&a// ERROR "&a escapes to heap"
isink=FooJ(a,b,c)// ERROR "a escapes to heap" "b escapes to heap" "c escapes to heap" "TFooJ2 ... argument does not escape"
}
typefakeSlicestruct{
lint
a*[4]interface{}
}
funcFooK(argsfakeSlice)*int32{// ERROR "leaking param: args to result ~r1 level=1"
fori:=0;i<args.l;i++{
switchx:=(*args.a)[i].(type){
casenil:
println("is nil")
caseint32:
println("is int32")
case*int32:
println("is *int32")
returnx
casestring:
println("is string")
}
}
returnnil
}
funcTFooK2(){
a:=int32(1)// ERROR "moved to heap: a"
b:="cat"
c:=&a// ERROR "&a escapes to heap"
fs:=fakeSlice{3,&[4]interface{}{a,b,c,nil}}// ERROR "a escapes to heap" "b escapes to heap" "c escapes to heap" "TFooK2 &\[4\]interface {} literal does not escape"
isink=FooK(fs)
}
funcFooL(args[]interface{})*int32{// ERROR "leaking param: args to result ~r1 level=1"
fori:=0;i<len(args);i++{
switchx:=args[i].(type){
casenil:
println("is nil")
caseint32:
println("is int32")
case*int32:
println("is *int32")
returnx
casestring:
println("is string")
}
}
returnnil
}
funcTFooL2(){
a:=int32(1)// ERROR "moved to heap: a"
b:="cat"
c:=&a// ERROR "&a escapes to heap"
s:=[]interface{}{a,b,c}// ERROR "a escapes to heap" "b escapes to heap" "c escapes to heap" "TFooL2 \[\]interface {} literal does not escape"