[perl #81944] Non-lvalue subs do not copy return values
return and leavesub see if they can cheat by not copying anything
marked TEMP, since presumably nothing else is using it. That means
the return values of delete() and shift() are not copied. Since @_
aliases to the caller’s variables, sometimes what is returned *is*
used elsewhere and still marked TEMP. So cases like sub { return
delete $_[0] } ->($x) end up returning $x unchanged, instead of
copying it.
As mentioned in the ticket, the solution is to copy only if the refer-
ence count is 1.
This also allows me to simplify the lvalue-returning code without
spreading this bug further. (pp_leavesublv currently avoids calling
sv_2mortal, in order not to set the TEMP flag.)