leibnitz27 / cfr

This is the public repository for the CFR Java decompiler

Home Page:https://www.benf.org/other/cfr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CFR may generate uninitialized variables for loop guard expressions

AIRTEspresso opened this issue · comments

CFR version

CFR version: 0.152

Compiler

Java openJDK, version: 11.0.13

Description

Here is another case that CFR may generate invalid Java code. When decompiling the loop structure shown in the example, CFR used a weird and uninitialized 'float f2', instead of 'f' in the loop guard expression.
The total case is available at error example and I hope it can be helpful.

Example

The source code:

class Test {
    double dFld;
    {
        float f = 1.18F;
        while(-- f > 0)dFld = f;
    }
}

The code decompiled by CFR:

class Test {
    double dFld;
    Test() {
        float f = 1.18f;
        while (true) {
            float f2;
            f -= 1.0f;
            if (!(f2 > 0.0f)) break;
            this.dFld = f;
        }
    }
}