Bug 116647 - [compiler] Incorrect warning about unnecessary cast
Summary: [compiler] Incorrect warning about unnecessary cast
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 121635 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-11-16 07:11 EST by Cameron Gregory CLA
Modified: 2006-02-15 09:19 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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