Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 173724

Summary: [compiler][null][correlation] incorrect "may be null" around ternary operator
Product: [Eclipse Project] JDT Reporter: Walter Harley <eclipse>
Component: CoreAssignee: Ayushman Jain <amj87.iitr>
Status: CLOSED DUPLICATE QA Contact:
Severity: enhancement    
Priority: P5 CC: stephan.herrmann
Version: 3.3Keywords: helpwanted
Target Milestone: 4.7 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Walter Harley CLA 2007-02-09 21:14:57 EST
The following code produces "The variable foo may be null":

  int f(String[] foo) {
    int size = (foo == null) ? 0 : foo.length;
    if (size == 0)
      return 0;
    return foo.length; // INCORRECT warning "foo may be null"
  }

I know, maybe this is asking too much from flow analysis :-)
Comment 1 Maxime Daniel CLA 2007-02-12 08:10:55 EST
We do not perform variables correlation (here size and foo), hence this is out of scope for now.
Comment 2 Maxime Daniel CLA 2007-06-19 08:09:07 EDT
Reopening as P5 (since RESOLVED LATER is deprecated).
Comment 3 Stephan Herrmann CLA 2016-06-28 17:18:03 EDT
Bulk closing all compiler bugs tagged [null][correlation], because we have no plans to add such a feature: it would be a tremendous implementation effort, beyond our current man power, and may be impossible to achieve within the desired performance bounds.

If s.o. has a viable strategy or even implementation for such a feature, I'm all ears.
Comment 4 Jay Arthanareeswaran CLA 2016-08-03 07:58:23 EDT
Verified for 4.7 M1.
Comment 5 Stephan Herrmann CLA 2018-08-30 10:35:32 EDT
I created a new umbrella RFE outlining what would be needed to address this issue.

*** This bug has been marked as a duplicate of bug 538421 ***