On Fri, Sep 8, 2023 at 10:27 AM Dave Mitchell <davem@iabyn.com> wrote: > Here is a classic example of the bug. Examine this code carefully: > > @a = qw(aaa bbb); > f(@a); > > sub f { > # on entry, $_[0] is an alias of $a[0], > # $_[1] is an alias of $a[1], > print "@_\n"; # correctly prints "aaa bbb" > > @a = (); # this prematurely frees $_[0] and $_[1] > > # this causes the two just-freed SVs to be reallocated > my $x = 'xxx:yyy'; my @x = split /:/, $x; > > # but the two reallocated SVs are still referenced by @_ > print "@_\n"; # incorrectly prints "xxx yyy" > } > Well that's terrifying. +1 from me, thanks Dave!Thread Previous | Thread Next