Running constant propagation on this Java code:

public class Foo
{
public void foo()
{
int x = 10;

             while (something())
             {
                     x = 5;
                     if (cond())
                     {
                             x = 10;
                     }
                     else
                     {}

                     call(x);
             }
     }

}

should not propagate x = 5 in the call(x) inside the while, but it does. However, changing the assignment x = 10 in the if (cond()) to x = 1 (or anything other than 10 for that matter) makes constant propagation behave correctly again.

Submitted on 2 March 2006 at 18:11

On 7 March 2006 at 15:17 Jira commented:

STR-528, bdumitriu:
This has the same root cause as STR-511. Both set- and add-in-rule-scope do not work properly in all cases when multiple change sets are created.


On 27 April 2006 at 15:09 Jira commented:

STR-528, bdumitriu:
Easier code to generate the same problem:

int x = 0;

if (cond()) {
x = 1;
if (cond()) {
x = 0;
f(x);
}
}

x = 1 will be propagated in f(x).

Log in to post comments