Bug 29501 - Uninitialized variable warning does not analyze the program thoroughly enough
Summary: Uninitialized variable warning does not analyze the program thoroughly enough
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 2.1 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-15 02:23 EST by Oyvind Harboe CLA
Modified: 2003-01-15 04:58 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oyvind Harboe CLA 2003-01-15 02:23:47 EST
The warning below shows up when it shouldn't, the first iteration of the code 
loop always executes.

Similar cases can be constructed with if() statements.



/**
 * @author oharboe
 */
public class Test
{

	public int foo()
	{
		int t;
		for (int i=0; i<10; i++)
		{
			t=1*i;
		}
		// The local variable t may not have been initialized		
		return t;
	}
}
Comment 1 Philipe Mulet CLA 2003-01-15 04:56:55 EST
This is a consequence of the conservative definite assignment rules described 
in JLS (chapter 16).

In brief, the analysis doesn't look deep enough to figure that it will perform 
at least one iteration in the loop (it could since only constants are involved, 
but this is the conservative spec we implement).

Javac and Jikes behave in the same way.
Comment 2 Philipe Mulet CLA 2003-01-15 04:58:08 EST
Closing, following the JLS.