Don't let sv_setsv swipe temps in av_make, since the source array
might have multiple references to the same temp scalar (e.g. from
a list slice).
AvFILLp(av) = AvMAX(av) = size - 1;
for (i = 0; i < size; i++) {
assert (*strp);
+
+ /* Don't let sv_setsv swipe, since our source array might
+ have multiple references to the same temp scalar (e.g.
+ from a list slice) */
+
ary[i] = newSV(0);
- sv_setsv(ary[i], *strp);
+ sv_setsv_flags(ary[i], *strp,
+ SV_GMAGIC|SV_DO_COW_SVSETSV|SV_NOSTEAL);
strp++;
}
}
}
require "test.pl";
-plan( tests => 57 );
+plan( tests => 58 );
@foo = (1, 2, 3, 4);
cmp_ok($foo[0], '==', 1, 'first elem');
test_zero_args("do-returned list slice", do { (10,11)[2,3]; });
}
+{
+ # perl #20321
+ is (join('', @{[('abc'=~/./g)[0,1,2,1,0]]}), "abcba");
+}