Bug 185567

Summary: [compiler] dead bytecodes are generated inside optimized boolean condition
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 Flags: Olivier_Thomann: review+
Version: 3.3   
Target Milestone: 3.3 RC1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch none

Description Olivier Thomann CLA 2007-05-04 11:23:59 EDT
Using v_755, I got the following test case:
public class X {
	boolean b;

	X(boolean b1) {
		if ((b1 == (b = b1)) || (false && b1)) {
			System.out.println(b);
		}
	}
}

That leads to dead bytecodes:

  // Method descriptor #8 (Z)V
  // Stack: 4, Locals: 2
  X(boolean b1);
     0  aload_0 [this]
     1  invokespecial Object() [10]
     4  iload_1 [b1]
     5  aload_0 [this]
     6  iload_1 [b1]
     7  dup_x1
     8  putfield X.b : boolean [13]
    11  if_icmpeq 20
    14  goto 30
    17  goto 30
    20  getstatic System.out : PrintStream [15]
    23  aload_0 [this]
    24  getfield X.b : boolean [13]
    27  invokevirtual PrintStream.println(boolean) : void [21]
    30  return

The bytecode at pc 14 is dead.
Comment 1 Philipe Mulet CLA 2007-05-04 13:02:00 EDT
variation:
		if (b1 || !(true || b1)) {
			System.out.println(b1);
		}
Comment 2 Philipe Mulet CLA 2007-05-07 06:27:07 EDT
Created attachment 66071 [details]
Proposed patch
Comment 3 Philipe Mulet CLA 2007-05-07 06:29:08 EDT
Added BooleanTest#test044-049.
Oliver - pls review
Comment 4 Olivier Thomann CLA 2007-05-07 10:03:57 EDT
+1
Comment 5 Philipe Mulet CLA 2007-05-07 10:25:30 EDT
Released for 3.3RC1.
Fixed
Comment 6 Eric Jodet CLA 2007-05-15 05:37:42 EDT
Verified for 3.3 RC1 using I20070515-0010