Bug 45433 - Bug7 (and counting ;-): hundretAssignmentsToFinalVariable()
Summary: Bug7 (and counting ;-): hundretAssignmentsToFinalVariable()
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 2.1.3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-23 07:39 EDT by markusle CLA
Modified: 2004-03-01 13:40 EST (History)
1 user (show)

See Also:


Attachments
Compile fine using Eclipse compiler. It should report an error (402 bytes, text/plain)
2003-10-23 08:25 EDT, Olivier Thomann CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description markusle CLA 2003-10-23 07:39:02 EDT
/**
 * hundretAssignmentsToFinalVariable()
 * Javac reports:
 * "variable iCount might be assigned in loop"
 */
public static void hundretAssignmentsToFinalVariable(
	final boolean bStop,
	final String s //
) {
	final int iCount;
	for (int i = 0; true; i++) {
		iCount = i;
		if (i < 100) {
			continue;
		} else {
			break;
		}
	}
	System.out.println(iCount);
}
I hope you are not angry bcause of my (not so stupid) joke
ath the end of
   https://bugs.eclipse.org/bugs/show_bug.cgi?id=45357
(I think this bug becmose assigned to: Philippe Mulet
Comment 1 Olivier Thomann CLA 2003-10-23 08:25:00 EDT
Jikes 1.18 reports:
Found 1 semantic error compiling "D:/temp/X.java":

    13.                 iCount = i;
                        ^----^
*** Semantic Error: The blank final variable "iCount" cannot be assigned within 
the body of a loop that may execute more than once.

javac 1.4.2 reports:
X.java:13: variable iCount might be assigned in loop
                iCount = i;
                ^
1 error

I will attach the test case.
Comment 2 Olivier Thomann CLA 2003-10-23 08:25:30 EDT
Created attachment 6529 [details]
Compile fine using Eclipse compiler. It should report an error
Comment 3 Philipe Mulet CLA 2003-10-23 09:25:05 EDT
Good find. Flow analysis was checking loop assignment before merging init 
information from continue branch.

Fixed in latest. Regression test added: InitializationTest#test170
Comment 4 David Audel CLA 2003-11-20 10:39:44 EST
Verified.
Comment 5 Philipe Mulet CLA 2003-11-25 07:00:05 EST
Backported to 2.1.x stream
Comment 6 Frederic Fusier CLA 2004-03-01 13:40:35 EST
Verified for 2.1.3 with build M200402251535.