Bug 235546 - [compiler] different behavior than javac on definite assignment analysis involving infinite loop
Summary: [compiler] different behavior than javac on definite assignment analysis invo...
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 03:57 EDT by Maxime Daniel CLA
Modified: 2008-06-06 10:24 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 03:57:31 EDT
I20080530-1730

On the following code, javac reports an error while Eclipse does not:

public class X {
  public static void main(String args[]) {
	final int i;
	for (;true;) {
	  if (true) {
		break;
	  } else {
		i = 0;
	  }
	}
	i = 1; // javac reports an error here
  }
}
Comment 1 Maxime Daniel CLA 2008-06-04 04:01:08 EDT
Following JL3 §16, i is definitely unassigned before the second assignment iff it is so after true when false and before the only break that branches to the for statement. I believe that both conditions hold true, giving us right and javac wrong.
Closing as INVALID.
Comment 2 Maxime Daniel CLA 2008-06-04 08:41:22 EDT
Added AssignmentTest#56 and 57.
Comment 3 Frederic Fusier CLA 2008-06-06 10:24:52 EDT
Agreed that 'i' is definitely unassigned in this case reading the following rule in chapter JLS3 §16.2.12:
  . V is [un]assigned after a for statement iff both of the following are true:
    + Either a condition expression is not present or V is [un]assigned after
      the condition expression when false.
    + V is [un]assigned before every break statement for which the for statement
      is the break target.