On Wed, May 27, 2015 at 09:30:22PM +0100, Paul "LeoNerd" Evans wrote: > What's the conclusion here? Do I have to fix any code in ListUtils.xs > then? Well I think the provisional conclusion is that lc() et al are at fault. As to whether List::Util is doing anything wrong, the two differences between the first() implementation and perl's grep() implementation are: 1) grep temporarily increases the ref count of each SV it aliases to $_, via: # define DEFSV_set(sv) \ (SvREFCNT_dec(GvSV(PL_defgv)), GvSV(PL_defgv) = SvREFCNT_inc(sv)) 2) grep makes a mortal copy of each PADTMP it encounters. Either of those would make List::Util work with the bad lc/uc/etc in 5.20.0 and 5.22.0. The second of those was to fix #78194: Referencing a PADTMP twice produces two copies (which I don't fully understand from a cursory read of the ticket). The first, if nothing else, avoids crashes if the thing being iterated is freed elsewhere, e.g. use List::Util qw{ first }; use Devel::Peek; my $a = "A"; @a = (1); @b = first { shift @a; Dump $_ } @a; which outputs: SV = UNKNOWN(0xff) (0x1b19038) at 0x1af8f88 REFCNT = 0 FLAGS = () -- "Do not dabble in paradox, Edward, it puts you in danger of fortuitous wit." -- Lady Croom, "Arcadia"Thread Previous | Thread Next