From: Dave Mitchell Date: Mon, 3 May 2004 18:52:39 +0000 (+0000) Subject: [perl #29127] scalar delete of empty slice returned garbage X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9111c9c032460b8a1a0f3c5ec70114106769f656;p=p5sagit%2Fp5-mst-13.2.git [perl #29127] scalar delete of empty slice returned garbage p4raw-id: //depot/perl@22775 --- diff --git a/pp.c b/pp.c index a3e56d3..4ce7867 100644 --- a/pp.c +++ b/pp.c @@ -3795,7 +3795,10 @@ PP(pp_delete) SP = ORIGMARK; else if (gimme == G_SCALAR) { MARK = ORIGMARK; - *++MARK = *SP; + if (SP > MARK) + *++MARK = *SP; + else + *++MARK = &PL_sv_undef; SP = MARK; } } diff --git a/t/op/delete.t b/t/op/delete.t index 10a218b..53212a1 100755 --- a/t/op/delete.t +++ b/t/op/delete.t @@ -1,6 +1,6 @@ #!./perl -print "1..36\n"; +print "1..37\n"; # delete() on hash elements @@ -121,3 +121,11 @@ print @{$refary[0]} == 1 ? "ok 35\n" : "not ok 35 @list\n"; print "not " unless $a == $b && $b == $c; print "ok 36\n"; } + +{ + # [perl #29127] scalar delete of empty slice returned garbage + my %h; + my ($x,$y) = (1, scalar delete @h{()}); + print "not " if defined $y; + print "ok 37\n"; +}