Bug 116647

Summary: [compiler] Incorrect warning about unnecessary cast
Product: [Eclipse Project] JDT Reporter: Cameron Gregory <public>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: veronika_irvine
Version: 3.2   
Target Milestone: 3.2 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Cameron Gregory CLA 2005-11-16 07:11:18 EST
type cast from int -> byte -> int gives incorrect warning about unnecessary
cast. As you can see in the example, the cast is required, else you get a
different result.
eclipse 3.2m3, jdk 1.5.0_05

thanks,

Cameron


/**
 * 
 * @author Cameron Gregory, http://www.bloke.com/
 */
public class TestByte {

    /**
     * @param args
     */
    public static void main(String[] args) {
        int i = 256;
        int j = (byte)i;  // here.
        System.out.println(j);
    }
}
Comment 1 Philipe Mulet CLA 2005-11-16 08:51:20 EST
Indeed.
Comment 2 Olivier Thomann CLA 2006-01-03 09:58:38 EST
*** Bug 121635 has been marked as a duplicate of this bug. ***
Comment 3 Philipe Mulet CLA 2006-02-10 05:09:32 EST
Fixed in 3.2 stream (HEAD). Pb did not exist in 3.1.x stream (unused cast in assign expressions were not diagnosed there).

Added CastTest#test040.
Note: it is not part of the warmup build.
Comment 4 Jerome Lanneluc CLA 2006-02-15 09:19:17 EST
Verified for 3.2 M5 using build I20060215-0010