Bug 28298 - SANITY CHECK error when compiling a specific switch statement
Summary: SANITY CHECK error when compiling a specific switch statement
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-12-13 15:41 EST by Olivier Thomann CLA
Modified: 2002-12-18 05:05 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 Olivier Thomann CLA 2002-12-13 15:41:17 EST
Using latest code, I got a SANITY CHECK error compiling the following code with
debug attributes:

public class X {
	public static void main(String[] args) {
		switch (args.length) {
			case 1 :
				if (true)
					break;
				int i = 1;
			case 0 :
				i = 2;
				System.out.print(i);
		}
	}
}

The result should be:
2

Using M3 or 2.0.2 leads to the same problem. So we always had this error, it is
not something new. I think I successfully compiled it once, because I didn't
generate the debug attributes.
Comment 1 Olivier Thomann CLA 2002-12-13 15:44:16 EST
javac 1.4.1 cannot compile this code successfully.
It has a VerifyError at runtime.
Exception in thread "main" java.lang.VerifyError: (class: X, method: main
signature: ([Ljava/lang/String;)V) Accessing value from uninitialized register 0
Comment 2 Olivier Thomann CLA 2002-12-13 15:44:38 EST
Jikes 1.18 compiles it fine.
Comment 3 Olivier Thomann CLA 2002-12-13 15:52:16 EST
I think adding the local declaration to the list of visible locals before
returning because the local is not reachable is ok, because this has no effect
on the range of local initializations. It simply adds the local binding to the
list of visible locals in the code stream and this is the list used to close the
locals at the end of the switch statement. So I won't see the local when it is
not initialized in the debugger it I do that.

Comment 4 Philipe Mulet CLA 2002-12-13 17:57:56 EST
Indeed, you're right. The variable should be added since it got allocated a 
position.

Comment 5 Philipe Mulet CLA 2002-12-13 17:58:18 EST
Fixed
Comment 6 David Audel CLA 2002-12-18 05:05:44 EST
Verified.