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:
Rafael Garcia-Suarez
Date:
November 19, 2003 12:42
Subject:
Re: [perl #24508] Wrong assignment in nested assignment together with subroutine ca ll
Message ID:
20031119214249.481fbf6c.rgarciasuarez@free.fr
Dave Mitchell wrote:
> > > 
> > >   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).

I'm tempted to apply the fix below. (Look closer.)
Thoughts ?

Index: opcode.pl
===================================================================
--- opcode.pl	(revision 2824)
+++ opcode.pl	(working copy)
@@ -537,7 +537,7 @@
 i_add		integer addition (+)	ck_null		ifsT2	S S
 subtract	subtraction (-)		ck_null		IfsT2	S S
 i_subtract	integer subtraction (-)	ck_null		ifsT2	S S
-concat		concatenation (.) or string	ck_concat	fsT2	S S
+concat		concatenation (.) or string	ck_concat	fst2	S S
 stringify	string			ck_fun		fsT@	S
 
 left_shift	left bitshift (<<)	ck_bitop	fsT2	S S
End of fix.

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