This is a migrated thread and some comments may be shown as answers.

Continue statements decompiled as goto LabelAtEndOfLoop

3 Answers 56 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Orvid
Top achievements
Rank 1
Orvid asked on 02 Dec 2012, 07:58 PM
Currently a continue statement is getting decompiled as a goto statement that jumps to a label at the end of the loop. While yes, this is the correct behavior for a continue statement, the placement of the label is not valid in C#, because there is no statement after it. I think that it should be fairly easy to implement this by searching up the AST and locating the first loop statement, if the end of that loop statement is the same as the target of the branch, it is a continue statement. Also, this would still leave situations where a goto statement was used to continue in a loop that is farther up broken, for these I would suggest putting a continue statement at the end of the loop immediately after the label, because this would achieve the desired effect. (and is likely how the code was written to begin with) 

A block of code illustrating the issue, as it is currently decompiled:
for (int i = 0; i < 32; i++)
{
    if (SomeBoolean)
        goto EndOfLoop;
    // SomeOtherCodeHere
EndOfLoop:
}

That should be getting decompiled as:
for (int i = 0; i < 32; i++)
{
    if (SomeBoolean)
        continue;
    // SomeOtherCodeHere
}

Now, the second issue is a bit more confusing, so I'll instead start with what the original code would have been.
for (int i = 0; i < 32; i++)
{
    for (int i2 = 0; i2 < 43; i2++)
    {
        if (SomeBoolean)
            goto EndOfOuterLoop;
          // SomeOtherCodeHere
    } 
EndOfOuterLoop:
    continue;
}

Currently, this would be missing the continue statement at the end of the outer loop, which is needed for it to be valid C#.

3 Answers, 1 is accepted

Sort by
0
Yordan Dikov
Telerik team
answered on 04 Dec 2012, 09:41 AM
Hi Orvid,

Thank you for contacting us. We've logged the problems you've observed and we'll try to provide a fix in one of our future releases. Until then, keep updating and don't hesitate to contact us, should you have any other questions or suggestions.

Greetings,
Yordan Dikov
the Telerik team
Tell us what you think about JustDecompile. Your opinion matters! You can use our forum, or our JustDecompile UserVoice website for feature requests.
0
Top achievements
Rank 1
answered on 10 Aug 2016, 10:26 AM
4 years have passed , this problem is still unsolved .
0
Alexander
Telerik team
answered on 15 Aug 2016, 01:10 PM
Hello,

Rather unfortunately, because of our finite resources we didn't get to this problem yet. It will be fixed at some point, but we cannot really commit on a deadline, so please, update regularly.

Regards,
Alexander
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Orvid
Top achievements
Rank 1
Answers by
Yordan Dikov
Telerik team
Top achievements
Rank 1
Alexander
Telerik team
Share this question
or