develooper Front page | perl.perl5.porters | Postings from November 2003

Re: [perl #24508] Wrong assignment in nested assignment together with subroutine ca ll

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
November 18, 2003 05:20
Subject:
Re: [perl #24508] Wrong assignment in nested assignment together with subroutine ca ll
Message ID:
20031118132024.GD13634@fdgroup.com
On Tue, Nov 18, 2003 at 01:55:41PM +0100, Rafael Garcia-Suarez wrote:
> Jeff 'japhy' Pinyan wrote:
> > 
> > This only happens with lexicals.
> > 
> >   my ($A, $B);
> >   $B = ($A = '' . foo()) . "y";
> >   $D = ($C = '' . foo()) . "y";
> >   print "$A,$B\n";  # xy,xy
> >   print "$C,$D\n";  # x,xy
> > 
> >   sub foo { "x" }
> 
> Ouch.
> I can reproduce it with 5.6.1, but not with 5.5.3.
> Looks like an optree optimization problem.

Both the inner and outer OP_CONCATs have the TEMP target optimised away;
the inner one uses the lexical as the target instead, and the outer one is
STACKED, so it uses the previous result as the target (which happens to be
the lexical).

> Andreas, could you try this below with binsearchaperl ?
> 
> #!perl
> sub foo { "x" }
> my ($A, $B);
> $B = ($A = '' . foo()) . "y";
> print "$A,$B" eq "x,xy" ? "ok\n" : "not ok\n";
> __END__

Looks like 3612 judging by these excerpts from the log:

____________________________________________________________________________

[  4749] By: gsar                                  on 2000/01/02  21:37:29
        Log: disable optimization in change#3612 for join() and quotemeta()--this
             removes all the gross hacks for the special cases in that change; fix
             pp_concat() for when TARG == arg (modified version of patch suggested
             by Ilya Zakharevich)
     Branch: perl
	   ! op.c opcode.h opcode.pl pp_hot.c sv.c t/op/lex_assign.t
____________________________________________________________________________
[  4543] By: gsar                                  on 1999/11/10  01:52:22
        Log: remove dead branch/infinite looper in change#3612
     Branch: perl
	   ! op.c
____________________________________________________________________________
[  4415] By: gsar                                  on 1999/10/20  00:52:34
        Log: disable optimizing troublesome ops in change#3612
             (from Ilya Zakharevich)
     Branch: perl
	   ! Makefile.SH opcode.h opcode.pl
____________________________________________________________________________
[  4087] By: gsar                                  on 1999/09/06  18:06:06
        Log: change#3612 is buggy when quotemeta argument matches target
             (hope this is the last of the optimized-OP_SASSIGN bugs)
             From: Ilya Zakharevich <ilya@math.ohio-state.edu>
             Date: Sun, 5 Sep 1999 06:07:42 -0400 (EDT)
             Message-Id: <199909051007.GAA06423@monk.mps.ohio-state.edu>
             Subject: Re: [BUG: quotemeta]
     Branch: perl
	   ! Changes op.c t/op/lex_assign.t
____________________________________________________________________________
[  3854] By: gsar                                  on 1999/08/01  20:41:53
        Log: fixes from Stephen McCamant that address bugs in change#3612
             (the optimization shouldn't be enabled in expressions where
             the variable is introduced), and fix Deparse to grok the
             optimization
             Date: Thu, 29 Jul 1999 21:21:49 -0500 (CDT)
             Message-ID: <14241.3133.979257.953396@alias-2.pr.mcs.net>
             Subject: [PATCH _58] Set OPpTARGET_MY more consistently
             --
             Date: Thu, 29 Jul 1999 22:31:16 -0500 (CDT)
             Message-ID: <14241.7300.181386.763503@alias-2.pr.mcs.net>
             Subject: [PATCH _58] Disable TARGET_MY-ization on variable introduction
             --
             Date: Fri, 30 Jul 1999 22:25:27 -0500 (CDT)
             Message-Id: <199907310326.VAA24376@localhost.frii.com>
             Subject: [PATCH _58, long] B::Deparse (was Re: New warning 'Useless use of...')
     Branch: perl
	   ! ext/B/B/Deparse.pm op.c
____________________________________________________________________________
[  3664] By: gsar                                  on 1999/07/11  19:11:07
        Log: change#3612 was buggy and failed to build Tk; applied Ilya's
             remedy and related tests via private mail
     Branch: perl
           ! op.c t/op/lex_assign.t
____________________________________________________________________________
[  3612] By: gsar                                  on 1999/07/06  10:17:52
        Log: From: Ilya Zakharevich <ilya@math.ohio-state.edu>
             Date: Sat, 12 Jun 1999 04:49:09 -0400 (EDT)
             Message-Id: <199906120849.EAA26986@monk.mps.ohio-state.edu>
             Subject: [PATCH 5.005_57] Optimize away OP_SASSIGN
     Branch: perl
           ! op.c op.h opcode.h opcode.pl pp.h pp.sym pp_proto.h



-- 
A walk of a thousand miles begins with a single step...
then continues for another 1,999,999 or so.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About