You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The CFG generator should treat true specially when used as a while condition.
Consider the following class:
public class WhileTrueInitialization {
private final double field;
WhileTrueInitialization() {
double local;
while (true) {
local = 1;
break;
}
field = local;
}
}
WhileTrueInitialization.java:11: error: [assignment.type.incompatible] incompatible types in assignment.
field = local;
^
found : @UnknownInitialization @NonNull double
required: @Initialized @NonNull double
1 error
The problem is apparent from viewing the control flow graph: while (true) is treated like any other while construct in that there is a branch that skips the entire body. That is not possible when the condition is true, so the CFG should not include that branch.
This is a duplicate of #1727, but with a smaller test case.
The text was updated successfully, but these errors were encountered:
This PR fixes both issue #3249 and issue #1727, by adapting the CFG in the following way:
If the loop condition is checked to be a constant true (according to the same logic in javac flow analysis), then the loop condition does not have an else-branch, i.e. the block holding the loop condition is directly followed by the one holding the loop entry, instead of followed by a conditional block.
Fixes#1727 and Fixes#3249`
The CFG generator should treat
true
specially when used as awhile
condition.Consider the following class:
Running
yields
The problem is apparent from viewing the control flow graph:
while (true)
is treated like any otherwhile
construct in that there is a branch that skips the entire body. That is not possible when the condition istrue
, so the CFG should not include that branch.This is a duplicate of #1727, but with a smaller test case.
The text was updated successfully, but these errors were encountered: