Commit e62f956885 for perl
commit e62f9568855e46cb1c114e1ef030abe404a326ef
Author: Paul Evans <leonerd@leonerd.org.uk>
Date: Thu Nov 12 15:36:50 2026 +0000
pp_hot.c: Fix bitshift wraparound bug in pp_iter
Multivariable foreach vars past the 24th cannot be refaliases, so don't
attempt to evaluate a bitshift mask beyond this
Fixes [GH#25055]
diff --git a/pp_hot.c b/pp_hot.c
index f44db02f3e..19db6dd14c 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -5005,7 +5005,7 @@ PP(pp_iter)
IV ix;
IV inc;
- bool refalias_this = refalias_mask & (1<<i);
+ bool refalias_this = (i < 24) && (refalias_mask & (1<<i));
switch (type) {
diff --git a/t/op/for-many.t b/t/op/for-many.t
index 3903e32540..e390809a6a 100644
--- a/t/op/for-many.t
+++ b/t/op/for-many.t
@@ -558,4 +558,20 @@ is($continue, 'xx', 'continue reached twice');
refcount_is \@arry, 1+1, 'arry refcount 1 after loop';
}
+# GH#25055
+{
+ use feature qw( refaliasing declared_refs );
+ no warnings qw( experimental::refaliasing experimental::declared_refs );
+
+ my $output;
+ for my ( \@arr, $v1, $v2, $v3, $v4, $v5, $v6, $v7, $v8,
+ $v9, $v10, $v11, $v12, $v13, $v14, $v15, $v16,
+ $v17, $v18, $v19, $v20, $v21, $v22, $v23, $v24,
+ $v25, $v26, $v27, $v28, $v29, $v30, $v31, $v32 ) ( [0], 1 .. 32 ) {
+ $output = "arr=<@arr> v32=$v32";
+ }
+ is($output, "arr=<0> v32=32",
+ 'foreach refalias is not confused by U32 bitshift wraparound');
+}
+
done_testing();