On Fri, Jul 9, 2010 at 8:56 AM, Nicholas Clark <perlbug-followup@perl.org> wrote: > # New Ticket Created by Nicholas Clark > # Please include the string: [perl #76438] > # in the subject line of all future correspondence about this issue. > # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=76438 > > > > > This is a bug report for perl from nick@ccl4.org, > generated with the help of perlbug 1.39 running under perl 5.13.2. > > > ----------------------------------------------------------------- > [Please describe your issue here] > > $ ./perl -Ilib -MO=Deparse -e 'if ("Pie" eq "Good") {print}' > '???'; > -e syntax OK > > but > > $ ./perl -Ilib -MO=Deparse -e 'if ($a && "Pie" eq "Good") {print}' > if ($a and !1) { > print $_; > } > -e syntax OK > > which demonstrates that "Pie" eq "Good" is constant folded, but that the > optree for the block still exists. > > The peephole optimiser is correct not to optimise this to nothing, as it > can't know that $a is neither tied nor overloaded, so cannot assume that > the lookup of $a has no side effects. > > However, it can know that the conditional to the if block is always false, > and so could optimise away the ops for the block, freeing up their memory. > Hence the code should become > > $a and !1; > > or even the perl equivalent of > > (void) (bool) $a; Well actually, the 'bool' call was in scalar context, not void. JoshThread Previous | Thread Next