diff options
Diffstat (limited to 'test/escape4.go')
-rw-r--r-- | test/escape4.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/escape4.go b/test/escape4.go index cc3ac78f0..83bc8eb12 100644 --- a/test/escape4.go +++ b/test/escape4.go @@ -37,3 +37,21 @@ func f2() {} // ERROR "can inline f2" // No inline for panic, recover. func f3() { panic(1) } func f4() { recover() } + +func f5() *byte { + type T struct { + x [1]byte + } + t := new(T) // ERROR "new.T. escapes to heap" + return &t.x[0] // ERROR "&t.x.0. escapes to heap" +} + +func f6() *byte { + type T struct { + x struct { + y byte + } + } + t := new(T) // ERROR "new.T. escapes to heap" + return &t.x.y // ERROR "&t.x.y escapes to heap" +} |