Front page | perl.perl5.porters |
Postings from August 2011
[perl #98184] [PATCH] Use OPpDEREF for lvalue sub, such that the flags contains the deref type, instead of deriving it from the opchain.
Thread Previous
From:
Gerard Goossen
Date:
August 31, 2011 10:55
Subject:
[perl #98184] [PATCH] Use OPpDEREF for lvalue sub, such that the flags contains the deref type, instead of deriving it from the opchain.
Message ID:
rt-3.6.HEAD-31297-1314813323-1615.98184-75-0@perl.org
# New Ticket Created by Gerard Goossen
# Please include the string: [perl #98184]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=98184 >
This is a bug report for perl from gerard@ggoossen.net,
generated with the help of perlbug 1.39 running under perl 5.15.2.
>From 57e586dab7e727ea61a1f264e0c5cc665007bcdc Mon Sep 17 00:00:00 2001
From: Gerard Goossen <gerard@ggoossen.net>
Date: Wed, 31 Aug 2011 15:55:26 +0200
Subject: [PATCH] Use OPpDEREF for lvalue sub, such that the flags contains
the deref type, instead of deriving it from the opchain.
Also contains a test were using the opchain to determine the deref
type fails.
---
cop.h | 2 +-
op.c | 4 +++-
op.h | 2 +-
pp_ctl.c | 15 +++------------
t/op/sub_lval.t | 5 ++++-
5 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/cop.h b/cop.h
index 6512451..8cd8a8a 100644
--- a/cop.h
+++ b/cop.h
@@ -643,7 +643,7 @@ struct block_format {
? 0 : Perl_was_lvalue_sub(aTHX); \
PUSHSUB_BASE(cx) \
cx->blk_u16 = PL_op->op_private & \
- (phlags|OPpENTERSUB_DEREF); \
+ (phlags|OPpDEREF); \
}
/* variant for use by OP_DBSTATE, where op_private holds hint bits */
diff --git a/op.c b/op.c
index 2b31f09..1d2b437 100644
--- a/op.c
+++ b/op.c
@@ -2177,7 +2177,9 @@ Perl_doref(pTHX_ OP *o, I32 type, bool set_op_ref)
o->op_private &= ~1;
}
else if (type == OP_RV2SV || type == OP_RV2AV || type == OP_RV2HV){
- o->op_private |= OPpENTERSUB_DEREF;
+ o->op_private |= (type == OP_RV2AV ? OPpDEREF_AV
+ : type == OP_RV2HV ? OPpDEREF_HV
+ : OPpDEREF_SV);
o->op_flags |= OPf_MOD;
}
diff --git a/op.h b/op.h
index 70b6358..903f7cd 100644
--- a/op.h
+++ b/op.h
@@ -206,7 +206,7 @@ Deprecated. Use C<GIMME_V> instead.
#define OPpENTERSUB_DB 16 /* Debug subroutine. */
#define OPpENTERSUB_HASTARG 4 /* Called from OP tree. */
#define OPpENTERSUB_INARGS 1 /* Lval used as arg to a sub. */
-#define OPpENTERSUB_DEREF 32 /* Lval call that autovivifies. */
+/* used by OPpDEREF (32|64) */
/* used by HINT_STRICT_SUBS 2 */
/* Mask for OP_ENTERSUB flags, the absence of which must be propagated
in dynamic context */
diff --git a/pp_ctl.c b/pp_ctl.c
index 67b11e3..0d2aae1 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2365,24 +2365,15 @@ S_return_lvalues(pTHX_ SV **mark, SV **sp, SV **newsp, I32 gimme,
EXTEND(newsp,1);
*++newsp = &PL_sv_undef;
}
- if (CxLVAL(cx) & OPpENTERSUB_DEREF) {
+ if (CxLVAL(cx) & OPpDEREF) {
SvGETMAGIC(TOPs);
if (!SvOK(TOPs)) {
- U8 deref_type;
- if (cx->blk_sub.retop->op_type == OP_RV2SV)
- deref_type = OPpDEREF_SV;
- else if (cx->blk_sub.retop->op_type == OP_RV2AV)
- deref_type = OPpDEREF_AV;
- else {
- assert(cx->blk_sub.retop->op_type == OP_RV2HV);
- deref_type = OPpDEREF_HV;
- }
- TOPs = vivify_ref(TOPs, deref_type);
+ TOPs = vivify_ref(TOPs, CxLVAL(cx) & OPpDEREF);
}
}
}
else if (gimme == G_ARRAY) {
- assert (!(CxLVAL(cx) & OPpENTERSUB_DEREF));
+ assert (!(CxLVAL(cx) & OPpDEREF));
if (ref || !CxLVAL(cx))
while (++MARK <= SP)
*++newsp =
diff --git a/t/op/sub_lval.t b/t/op/sub_lval.t
index f34fab9..ce5da8d 100644
--- a/t/op/sub_lval.t
+++ b/t/op/sub_lval.t
@@ -3,7 +3,7 @@ BEGIN {
@INC = '../lib';
require './test.pl';
}
-plan tests=>179;
+plan tests=>181;
sub a : lvalue { my $a = 34; ${\(bless \$a)} } # Return a temporary
sub b : lvalue { ${\shift} }
@@ -880,6 +880,9 @@ for my $sub (sub :lvalue {$_}, sub :lvalue {return $_}) {
undef $_;
%{&$sub()} = (4,5);
is join('-',%$_), '4-5', '%{func()} autovivification'.$suffix;
+ undef $_;
+ ${ (), &$sub()} = 4;
+ is $$_, 4, '${ (), func()} autovivification' .$suffix;
}
continue { $suffix = ' (explicit return)' }
--
1.7.5.4
---
Flags:
category=core
severity=low
---
Site configuration information for perl 5.15.2:
Configured by gerard at Wed Aug 31 16:05:28 CEST 2011.
Summary of my perl5 (revision 5 version 15 subversion 2) configuration:
Derived from: 01d5c162aa4c4b026e65e57d933dcebbe4c706a9
Platform:
osname=linux, osvers=3.0.0-1-686-pae, archname=i686-linux-thread-multi
uname='linux zeus 3.0.0-1-686-pae #1 smp sun jul 24 14:27:32 utc 2011 i686 gnulinux '
config_args='-des -Dusethreads -Dnoextensions= -Doptimize=-O3 -g3 -DDEBUGGING -Dusedevel -Dprefix=/home/gerard/perl/inst/blead-codegen'
hint=recommended, useposix=true, d_sigaction=define
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O3 -g3',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
ccversion='', gccversion='4.6.1', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib /usr/lib/i386-linux-gnu /usr/lib64
libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
libc=, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.13'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O3 -g3 -L/usr/local/lib -fstack-protector'
Locally applied patches:
---
@INC for perl 5.15.2:
lib
/home/gerard/perl/inst/blead-codegen/lib/site_perl/5.15.2/i686-linux-thread-multi
/home/gerard/perl/inst/blead-codegen/lib/site_perl/5.15.2
/home/gerard/perl/inst/blead-codegen/lib/5.15.2/i686-linux-thread-multi
/home/gerard/perl/inst/blead-codegen/lib/5.15.2
/home/gerard/perl/inst/blead-codegen/lib/site_perl
.
---
Environment for perl 5.15.2:
HOME=/home/gerard
LANG=en_US.UTF-8
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/home/gerard/bin:/usr/local/bin:/usr/bin:/bin:/usr/games
PERL_BADLANG (unset)
SHELL=/bin/bash
Thread Previous