in reply to Re: Use of freed value
in thread Use of freed value
call($x++, $x++) works in an unsurprising manner.
$ perl -e'$x=3; CORE::say for $x++, $x++' 3 4
I think you're referring to the oddities of call(++$x, ++$x).
$ perl -e'$x=3; CORE::say for ++$x, ++$x' 5 5
or
$ perl -e'$x=3; CORE::say for $x, $x++' 4 3
These occur because $x and ++$x (and --$x) add the scalar $x itself to the stack rather than a copy. $x++ (and $x--) necessarily add a copy of the original value.
Well, the problem is related to the scalars themselves being on the stack, so the explanations are indeed related. But that's just the precondition for the problem, not the answer itself.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Use of freed value
by LanX (Saint) on Jun 26, 2019 at 17:25 UTC | |
by ikegami (Patriarch) on Jun 27, 2019 at 11:48 UTC | |
by LanX (Saint) on Jun 27, 2019 at 22:43 UTC | |
by ikegami (Patriarch) on Jun 28, 2019 at 08:44 UTC | |
by LanX (Saint) on Jun 28, 2019 at 11:28 UTC |