-
-
Save lujjjh/02d89fd848ee72ce3dd47156fc97c184 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
//go:noinline | |
func foo() *int { | |
x := 42 | |
return &x | |
} | |
func fooInline() *int { | |
x := 42 | |
return &x | |
} | |
//go:noinline | |
func bar(p *int) { | |
*p = 42 | |
} | |
func main() { | |
var s struct{} | |
println("sp:", &s) | |
println("foo:", foo()) | |
println("fooInline:", fooInline()) | |
q := new(int) | |
bar(q) | |
println("bar:", q) | |
} | |
/* | |
sp: 0xc000056758 | |
foo: 0xc0000140b0 | |
fooInline: 0xc000056758 | |
bar: 0xc000056760 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment