Export to GitHub

perl-compiler - issue #37

||= doesn't work with B::CC


Posted on Aug 20, 2010 by Massive Bear

This test program fails with B::CC.

test6.pl

my $x; $x ||= 1;

print "x\n" if $x;

Expected output: $ perl test6.pl x

With B::CC the "||=" doesn't work. $ perlcc -O -o test6 test6.pl && ./test6

(nothing)

Used versions: - perl v5.10.1 (*) built for i486-linux-gnu-thread-mult (from Ubuntu 10.04) - B::C checked out today from repository.

Comment #1

Posted on Aug 22, 2010 by Massive Bear

Looking at the output of "perl -MO=Concise,-src test6.pl" we see

2: $x ||= 1;

6 <;> nextstate(main 2 test6.pl:2) v:{ ->7 - <1> null vK/1 ->b 8 <|> orassign(other->9) vK/1 ->b 7 <0> padsv[$x:1,2] sRM ->8 a <1> sassign sK/BKWARD,1 ->b 9 const[IV 1] s ->a There is an op "orassign" which seems to check the boolean value of the variable and then branches to one or the other basic block. B::CC currently handles "orassign" by "sub default_pp". But default_pp knows nothing about branching and hence always executes "op_next" but never "op_other". I think, all ops which do branching, can't be handled correctly by default_pp but should be implemented by separate functions.

Comment #2

Posted on Aug 23, 2010 by Grumpy Rhino

Thanks. orassign, dorassign and andassign are relatively new and not yet added. This should be simple to fix.

Comment #3

Posted on Sep 12, 2010 by Massive Bear

This has been fixed by r605.

Comment #4

Posted on Sep 12, 2010 by Massive Bear

dorassign has still to be fixed. See issue 45.

Status: Fixed

Labels:
Type-Defect Priority-Medium OpSys-All Component-Logic