On Sunday, May 23, 2021 at 5:22:23 AM UTC-4 Jan Mercl wrote:
> On Sun, May 23, 2021 at 11:11 AM tapi...@gmail.com <tapi...@gmail.com> > wrote: > > > > It says both "make([]T, N) does not escape" and "make([]T, N) escapes to > heap" for the slice allocated by g. > > What's conflicting about? You still did not explain that. > > I noted before that the code is different. Yes, the different code > shares the same single line. That means nothing. Different code, > different outcome. It would be unexpected iff the outcome would be > different for the same, not different code. > > Hint: When a slice is created in a function _and_ is returned as a > result of that function, it's backing array must escape - in the first > approximation at least. > I just try to confirm whether or not g will allocated on heap. I think It will not if g is inlined. But it will otherwise. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/1919c9bc-c7c6-4b57-9fe4-087dbad3d47fn%40googlegroups.com.