@INC = '../lib';
}
use warnings;
-print "1..141\n";
+print "1..143\n";
# these shouldn't hang
{
sort { while(1) {} } @a;
sort { while(1) { last; } } @a;
sort { while(0) { last; } } @a;
+
+ # Change 26011: Re: A surprising segfault
+ map scalar(sort(+())), ('')x68;
}
sub Backwards { $a lt $b ? 1 : $a gt $b ? -1 : 0 }
my $answer = "ok ";
() = sort OtherPack::foo 1,2,3,4;
-{package OtherPack; sub foo {
- $answer = "not ok " if
- defined($a) || defined($b) || !defined($main::a) || !defined($main::b);
- $main::a <=> $main::b;
-}}
+{
+ package OtherPack;
+ no warnings 'once';
+ sub foo {
+ $answer = "not ok " if
+ defined($a) || defined($b) || !defined($main::a) || !defined($main::b);
+ $main::a <=> $main::b;
+ }
+}
print $answer, $test++, "\n";
@b = sort {while (1) {return ($a <=> $b)} } 1..10;
ok("@b", "1 2 3 4 5 6 7 8 9 10", "return within loop");
-# Clearing the array we're sorting should be okay.
-@a = (1..10);
-@b = sort {@a=(); ($a+1)<=>($b+1)} @a;
-ok("@b", "1 2 3 4 5 6 7 8 9 10", "clear array being sorted");
+# Using return() should be okay even if there are other items
+# on the stack at the time.
+@b = sort {$_ = ($a<=>$b) + do{return $b<=> $a}} 1..10;
+ok("@b", "10 9 8 7 6 5 4 3 2 1", "return with SVs on stack");
+
+# As above, but with a sort sub rather than a sort block.
+sub ret_with_stacked { $_ = ($a<=>$b) + do {return $b <=> $a} }
+@b = sort ret_with_stacked 1..10;
+ok("@b", "10 9 8 7 6 5 4 3 2 1", "return with SVs on stack");