Bug 235555 - [compiler] difference to javac in definite unassignment analysis involving an assignment within the condition of a for loop
Summary: [compiler] difference to javac in definite unassignment analysis involving an...
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.4 RC4   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-04 05:05 EDT by Maxime Daniel CLA
Modified: 2008-06-06 10:45 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Maxime Daniel CLA 2008-06-04 05:05:09 EDT
I20080530-1730

On the following test case, javac raises an error while Eclipse does not:
public class X {
  public static void main(String args[]) {
	final int i;
	for (; 0 < (i /* javac error here */ = 1); i = i + 1) {
	  break;
	}
  }
}

javac does as we do (no error) for:

public class X {
  public static void main(String args[]) {
	final int i;
	for (; 0 < (i = 1);) {
	  break;
	}
  }
}
Comment 1 Maxime Daniel CLA 2008-06-04 05:05:33 EDT
My reading of JLS 3 $ 16.2.12 gives us right (note that, interestingly enough, it does not involve the incrementation part in the determination of definite unassignment before the condition part).
Comment 2 Maxime Daniel CLA 2008-06-04 09:07:39 EDT
Added AssignmentTest#59 and 60.
Comment 3 Maxime Daniel CLA 2008-06-05 05:46:08 EDT
This is discussed in http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4660984. Current status seems to be that the spec will change at some point in time. The discussion gives compelling reasons to consider it as a compiler bug though. Until javac and the spec align, we'll stick to our current position. 
Comment 4 Frederic Fusier CLA 2008-06-06 10:45:49 EDT
In reply to comment #1)
> My reading of JLS 3 $ 16.2.12 gives us right (note that, interestingly enough,
> it does not involve the incrementation part in the determination of definite
> unassignment before the condition part).
> 
Agreed with this point. Looking at the spec, I find it hard to say precisely how the 'Incrementation Part' influences the determination of definite [un]assignment, typically in this peculiar case...

So, in doubt I would say verified for 3.4RC4 and we'll see the result of the discussion on Sun's bug...