ARudik / phc

Automatically exported from code.google.com/p/phc
0 stars 0 forks source link

Pre operation lacking recording the variable use #127

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello everyone,

  I've encountered a bug in phc on the pre operation handler. It's failing to record a use that's making its definition getting killed on the DCE pass.

  More details as follow. Consider the program below:

<?php
  $i = $_ENV['x'];
  $i++;
  echo $i;
?>

After the first whole program iteration, the "$i = $_ENV['x']" gets kill on 
DCE, because the instruction "$i++" is not recording the use for variable $i. 
This resulted in the following program:

<?php
  $i++;
  echo $i;
?>

On the next iteration, the "$i" variable is not defined, hence its constant 
value can be propagated as 0. So, 0++ equals to 1. The resultant (erroneous) 
optimized code is:

<?php
  echo 1;
?>

Original issue reported on code.google.com by logyt...@gmail.com on 21 Sep 2010 at 2:00

GoogleCodeExporter commented 9 years ago
Fixed on revision 3352.

Original comment by logyt...@gmail.com on 21 Sep 2010 at 2:05