In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/b48c4cbac0e21d2d8ae2c5f1929b2a4761dc9868?hp=dacd91898fcfc21090ad48dd88483172a4bc8914>
- Log ----------------------------------------------------------------- commit b48c4cbac0e21d2d8ae2c5f1929b2a4761dc9868 Author: David Mitchell <[email protected]> Date: Wed Dec 10 13:20:38 2014 +0000 fix spurious 'Use of reference' warning My recent OP_MULTIDEREF addition introduced a bug where, when converting a constant array index into a UV, it checked for a ref and issued a "Use of reference "HASH(0x7fd190915ba8)" as array index" warning *before* it had confirmed that the OP_CONST was the only op in the index expression. So things like use constant HASHREF => { a => 1 }; () = $_[HASHREF->{a} ]; would generate two spurious warnings. The fix is easy. Only test for the warning on the second pass; we'll already have abandoned the optimisation attempt on the first pass if the index expression isn't a simple constant. ----------------------------------------------------------------------- Summary of changes: op.c | 2 +- t/lib/warnings/pp_hot | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/op.c b/op.c index c168c64..cef99f2 100644 --- a/op.c +++ b/op.c @@ -12398,7 +12398,7 @@ S_maybe_multideref(pTHX_ OP *start, OP *orig_o, UV orig_action, U8 hints) else { /* it's a constant array index */ SV *ix_sv = cSVOPo->op_sv; - if (UNLIKELY(SvROK(ix_sv) && !SvGAMAGIC(ix_sv) + if (pass && UNLIKELY(SvROK(ix_sv) && !SvGAMAGIC(ix_sv) && ckWARN(WARN_MISC))) Perl_warner(aTHX_ packWARN(WARN_MISC), "Use of reference \"%"SVf"\" as array index", diff --git a/t/lib/warnings/pp_hot b/t/lib/warnings/pp_hot index 4e63073..702df08 100644 --- a/t/lib/warnings/pp_hot +++ b/t/lib/warnings/pp_hot @@ -343,3 +343,17 @@ print $x[$b]; EXPECT OPTION regex Use of reference ".*" as array index at - line 7. +######## +use warnings 'misc'; +use constant FOO => { a => 1 }; +() = $_[FOO->{a}]; + +EXPECT +######## +use warnings 'misc'; +use constant FOO => {}; +() = $_[FOO]; + +EXPECT +OPTION regex +Use of reference "HASH\(0x\w+\)" as array index at - line 3. -- Perl5 Master Repository
