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 gives strange decompilation to guard expressions of loops

AIRTEspresso opened this issue · comments

CFR version

CFR version: 0.152

Compiler

Java openJDK, version: 11.0.13

Description

Here is one more case that the code generated by CFR gave different execution results compared with the source code. CFR gives strange translation to guard expressions of loops: for the '++i7 < 7' expression in the while-loop in the source code, CFR generated 'if (++n4 < 7) continue', which are not equivalent at not. It makes the decompiled code hang and never end.
The total case is available at error example and I hope it can be helpful.

Example

The source code:

    public void vMeth1() {
        int i4=53, i5=-58396, i6=-8681, i7=-8, i8=11268, i9=21390;
        byte by=36;
        boolean b=false;
        i4 &= (int)Test.instanceCount;
        by = (byte)i6;
        i6 = i6;
        Test.instanceCount += (long)26.895F;
        i7 = 1;
        do {
            if (b) break;
            b = b;
            for (i8 = 1; 1 > i8; ++i8) {
                i4 = (int)Test.instanceCount;
                i9 = 225;
            }
        } while (++i7 < 7);
        vMeth1_check_sum += i4 + i5 + i6 + by + i7 + (b ? 1 : 0) + i8 + i9;
    }

The code decompiled by CFR:

    public void vMeth1() {
        int n = 53;
        int n2 = -58396;
        int n3 = -8681;
        int n4 = -8;
        int n5 = 11268;
        int n6 = 21390;
        int n7 = 36;
        boolean bl = false;
        n &= (int)instanceCount;
        n7 = (byte)n3;
        instanceCount += 26L;
        n4 = 1;
        while (!bl) {
            for (n5 = 1; 1 > n5; ++n5) {
                n = (int)instanceCount;
                n6 = 225;
            }
            if (++n4 < 7) continue;
        }
        vMeth1_check_sum += (long)(n + n2 + n3 + n7 + n4 + (bl ? 1 : 0) + n5 + n6);
    }