On Sun, May 23, 2021 at 11:11 AM tapi...@gmail.com <tapir....@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.

-- 
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/CAA40n-WN0DDTaLiN-EimMQNBZq1KToTUGM8t9DtkorkLKSSZMA%40mail.gmail.com.

Reply via email to