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

False Positive: IL_INFINITE_LOOP #2936

Open
raghucssit opened this issue Apr 10, 2024 · 6 comments
Open

False Positive: IL_INFINITE_LOOP #2936

raghucssit opened this issue Apr 10, 2024 · 6 comments

Comments

@raghucssit
Copy link

public class TestClass {

    public void sampleMethod() throws Exception {

        // some random last index.
        int lastIndex_o1_n1 = 5;
        // start index is always higher than start index.
        int startIndex_o1 = lastIndex_o1_n1 + 1;
        // Loop can't be entered because start is higher.
        for (int i = startIndex_o1; i <= lastIndex_o1_n1; i++) {
            System.out.println("Loop can't be entered. So can never go infinite.");
        }
    }

    public static void main(String[] args) throws Exception {
        new TestClass().sampleMethod();
    }
}

image

Copy link

welcome bot commented Apr 10, 2024

Thanks for opening your first issue here! 😃
Please check our contributing guideline. Especially when you report a problem, make sure you share a Minimal, Complete, and Verifiable example to reproduce it in this issue.

@raghucssit
Copy link
Author

This looks like an opposite case of Infinite loop.
i.e. Loop can never be entered making statements inside for loop useless.

@iloveeclipse
Copy link
Member

Loop can't be entered. So can never go infinite.

👍

@iloveeclipse
Copy link
Member

I wonder if this is just wrong bug / message reported?

@raghucssit
Copy link
Author

I think so. This is more of dead code scenario.

@JuditKnoll
Copy link
Collaborator

I think #2073 could help solve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants