lovubuntu / checker-framework

Automatically exported from code.google.com/p/checker-framework
0 stars 0 forks source link

Flow analysis bug with ternary operator #277

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The nullness checker incorrectly reports a possible null dereference in the 
following snippet.

I tested with the 1.7.0 release.

===

import checkers.nullness.quals.*;

abstract class Ternary {
  void f(@Nullable Object o) {
    g(42, o != null ? o.hashCode() : 0);
  }

  abstract void g(Object x, Object xs);
}

===

Original issue reported on code.google.com by cus...@google.com on 21 Nov 2013 at 2:11

GoogleCodeExporter commented 9 years ago
I have confirmed this and added a test case:  
checkers/tests/nullness/Ternary.java

Original comment by michael.ernst@gmail.com on 21 Nov 2013 at 4:00

GoogleCodeExporter commented 9 years ago

Original comment by mer...@cs.washington.edu on 21 Nov 2013 at 8:31

GoogleCodeExporter commented 9 years ago
The problem was that method invocation arguments were having CFG nodes 
generated in a batch and then converted (i.e. boxed/unboxed) in a batch, which 
disturbed labels and resulted in an incorrect CFG with missing nodes.  It's 
been changed to generate and convert each method argument one by one (changeset 
7229).

This seemed to fix the problem and I've unskipped the test.

Original comment by charlie....@gmail.com on 22 Nov 2013 at 4:49