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

Warn on NewArray with potentially negative expr #153

Open
problame opened this issue Nov 30, 2018 · 0 comments
Open

Warn on NewArray with potentially negative expr #153

problame opened this issue Nov 30, 2018 · 0 comments
Labels
enhancement New feature or request
Projects
Milestone

Comments

@problame
Copy link
Contributor

class Main {
    public static void main(String[] args) {
        int x = System.in.read();
        int[] foo = new int[x];

        if y = System.in.read();
        if (y <= 0) {
           return;
        }
        int[] bar = new int[y];
   }
}

x could be negative. Warn for that line.

y cannot be negative after the if stmt, so don't warn there.

@problame problame added the enhancement New feature or request label Nov 30, 2018
@problame problame added this to the Optimizations milestone Nov 30, 2018
@problame problame added this to Todo !(optimization OR backend) in Endspurt Feb 4, 2019
@problame problame moved this from General Todo to Todo Safety in Endspurt Feb 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Endspurt
  
Todo Safety
Development

No branches or pull requests

1 participant