Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use break block instead of goto #118

Open
rfalke opened this issue Oct 29, 2018 · 1 comment
Open

Use break block instead of goto #118

rfalke opened this issue Oct 29, 2018 · 1 comment
Labels
dom: codegen (P/I) Related to high level code output type: bug (I) Something is not working as intended

Comments

@rfalke
Copy link

rfalke commented Oct 29, 2018

Version: ed7a3e1
Exe: https://github.com/rfalke/decompiler-subjects/blob/master/from_holdec/dmi/cfg/ia32_elf/subject.exe
Source:

int intermediate_12_loop_with_break_and_block(int arg)
{
        while (1) {
                puts("head");
                if (time(0) == arg) {
                        puts("will break");
                        break;
                }
                puts("barrier");
                if (rand() == arg) {
                        break;
                }
                puts("tail");
        }
        return 0;
}

Output:

/** address: 0x08048830 */
void intermediate_12_loop_with_break_and_block(__size32 param1)
{
    int eax;            // r24

    for(;;) {
        puts("head");
        eax = time(0);
        if (eax != param1) {
            puts("barrier");
            eax = rand();
            if (param1 == eax) {
                return;
            }
            puts("tail");
        }
        else {
            goto bb0x8048889;
        }
        return;
    }
bb0x8048889:
    puts("will break");
    return;
}

Instead of the goto should be the puts("will break"); and either a break or return.

@rfalke
Copy link
Author

rfalke commented Oct 29, 2018

Same problem with continue blocks in intermediate_15_loop_with_continue_and_block()

@ceeac ceeac added type: bug (I) Something is not working as intended dom: codegen (P/I) Related to high level code output labels Oct 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dom: codegen (P/I) Related to high level code output type: bug (I) Something is not working as intended
Projects
None yet
Development

No branches or pull requests

2 participants