New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty tied hash delete in scalar context seems to pick up random trash from the stack #7265
Comments
From perl-5.8.0@ton.iguana.beCreated by perl-5.8.0@ton.iguana.be#! /usr/bin/perl -wl sub TIEHASH { my $tie = tie my %cache, "main"; This will print: The first print seems to pick up the "foo=" that's pending and prints Perl Info
|
From perl5-porters@ton.iguana.beIn article <rt-3.0.8-29127-86013.2.58320876738814@perl.org>,
The tie is a red herring. It happens like this too: #! /usr/bin/perl -wl |
The RT System itself - Status changed from 'new' to 'open' |
From @iabynOn Wed, Apr 28, 2004 at 01:54:12PM +0000, Ton Hospel wrote:
fixed in belldperl by the change below. Dave. -- Change 22775 by davem@davem-percy on 2004/05/03 18:52:39 [perl #29127] scalar delete of empty slice returned garbage Affected files ... ... //depot/perl/pp.c#415 edit Differences ... ==== //depot/perl/pp.c#415 (text) ==== @@ -3795,7 +3795,10 @@ ==== //depot/perl/t/op/delete.t#9 (xtext) ==== @@ -1,6 +1,6 @@ -print "1..36\n"; # delete() on hash elements @@ -121,3 +121,11 @@ |
@iabyn - Status changed from 'open' to 'resolved' |
From @davidnicolHow do we feel about the conditional operator? the ternary conditional operator would make the patch smaller MARK = ORIGMARK; for that matter, I've written a patch generator -- running Attached: the file patcher tool and the resulting diff Dave Mitchell wrote: @@ -3795,7 +3795,10 @@ -- |
From @davidnicolfind_simple_ifsCURRENT.diffdiff -ru CURRENT/op.c perl-5.8.4-opt/op.c
--- CURRENT/op.c 2004-05-04 14:43:26.000000000 -0500
+++ perl-5.8.4-opt/op.c 2004-05-04 21:21:18.000000000 -0500
@@ -2445,10 +2445,7 @@
tdiff = tlast - tfirst;
rdiff = rlast - rfirst;
- if (tdiff <= rdiff)
- diff = tdiff;
- else
- diff = rdiff;
+ diff = tdiff <= rdiff ? tdiff : rdiff;
if (rfirst == 0xffffffff) {
diff = tdiff; /* oops, pretend rdiff is infinite */
@@ -2483,10 +2480,7 @@
if (max > 0xffff)
bits = 32;
- else if (max > 0xff)
- bits = 16;
- else
- bits = 8;
+ else bits = max > 0xff ? 16 : 8;
Safefree(cPVOPo->op_pv);
cSVOPo->op_sv = (SV*)swash_init("utf8", "", listsv, bits, none);
@@ -3352,10 +3346,7 @@
/* optimize "!a && b" to "a || b", and "!a || b" to "a && b" */
if (first->op_type == OP_NOT && (first->op_flags & OPf_SPECIAL)) {
if (type == OP_AND || type == OP_OR) {
- if (type == OP_AND)
- type = OP_OR;
- else
- type = OP_AND;
+ type = type == OP_AND ? OP_OR : OP_AND;
o = first;
first = *firstp = cUNOPo->op_first;
if (o->op_next)
diff -ru CURRENT/os2/os2.c perl-5.8.4-opt/os2/os2.c
--- CURRENT/os2/os2.c 2004-01-01 11:50:50.000000000 -0600
+++ perl-5.8.4-opt/os2/os2.c 2004-05-04 21:21:17.000000000 -0500
@@ -3567,10 +3567,7 @@
return Perl_rc;
if (type > 0)
what = END_LIBPATH;
- else if (type == 0)
- what = BEGIN_LIBPATH;
- else
- what = LIBPATHSTRICT;
+ else what = type == 0 ? BEGIN_LIBPATH : LIBPATHSTRICT;
return (*(PELP)f)(path, what);
}
diff -ru CURRENT/pp.c perl-5.8.4-opt/pp.c
--- CURRENT/pp.c 2004-05-03 14:17:25.000000000 -0500
+++ perl-5.8.4-opt/pp.c 2004-05-04 21:21:18.000000000 -0500
@@ -3795,10 +3795,7 @@
SP = ORIGMARK;
else if (gimme == G_SCALAR) {
MARK = ORIGMARK;
- if (SP > MARK)
- *++MARK = *SP;
- else
- *++MARK = &PL_sv_undef;
+ *++MARK = SP > MARK ? *SP : &PL_sv_undef;
SP = MARK;
}
}
diff -ru CURRENT/pp_hot.c perl-5.8.4-opt/pp_hot.c
--- CURRENT/pp_hot.c 2004-04-23 16:05:07.000000000 -0500
+++ perl-5.8.4-opt/pp_hot.c 2004-05-04 21:21:18.000000000 -0500
@@ -1891,10 +1891,7 @@
if (SvMAGICAL(av) || AvREIFY(av)) {
SV **svp = av_fetch(av, ++cx->blk_loop.iterix, FALSE);
- if (svp)
- sv = *svp;
- else
- sv = Nullsv;
+ sv = svp ? *svp : Nullsv;
}
else {
sv = AvARRAY(av)[++cx->blk_loop.iterix];
diff -ru CURRENT/pp_sys.c perl-5.8.4-opt/pp_sys.c
--- CURRENT/pp_sys.c 2004-03-16 12:42:23.000000000 -0600
+++ perl-5.8.4-opt/pp_sys.c 2004-05-04 21:21:18.000000000 -0500
@@ -1511,10 +1511,7 @@
STRLEN len;
int mode, perm;
- if (MAXARG > 3)
- perm = POPi;
- else
- perm = 0666;
+ perm = MAXARG > 3 ? POPi : 0666;
mode = POPi;
sv = POPs;
gv = (GV *)POPs;
@@ -3512,10 +3509,7 @@
SV **svp;
STRLEN n_a;
- if( MAXARG == 1 )
- tmps = POPpx;
- else
- tmps = 0;
+ tmps = MAXARG == 1 ? POPpx : 0;
if( !tmps || !*tmps ) {
if ( (svp = hv_fetch(GvHVn(PL_envgv), "HOME", 4, FALSE))
@@ -3805,10 +3799,7 @@
char *tmps;
bool copy = FALSE;
- if (MAXARG > 1)
- mode = POPi;
- else
- mode = 0777;
+ mode = MAXARG > 1 ? POPi : 0777;
TRIMSLASHES(tmps,len,copy);
diff -ru CURRENT/regcomp.c perl-5.8.4-opt/regcomp.c
--- CURRENT/regcomp.c 2004-04-19 03:55:17.000000000 -0500
+++ perl-5.8.4-opt/regcomp.c 2004-05-04 21:21:19.000000000 -0500
@@ -1916,10 +1916,7 @@
/* turn .* into ^.* with an implied $*=1 */
int type = OP(NEXTOPER(first));
- if (type == REG_ANY)
- type = ROPT_ANCH_MBOL;
- else
- type = ROPT_ANCH_SBOL;
+ type = type == REG_ANY ? ROPT_ANCH_MBOL : ROPT_ANCH_SBOL;
r->reganch |= type | ROPT_IMPLICIT;
first = NEXTOPER(first);
|
From @pjcjOn Tue, May 04, 2004 at 09:31:12PM -0500, David Nicol wrote:
Looks like undefined behaviour to me. -- |
Migrated from rt.perl.org#29127 (status was 'resolved')
Searchable as RT29127$
The text was updated successfully, but these errors were encountered: