Skip to content

Misleading cast.unsafe error #2731

@Kakarot-SSJ4

Description

@Kakarot-SSJ4

Consider the following code:

class cast_unsafe{
	static final float b = 0.75f;
       void casting(){
    	int c = (int)(b);
    }
}

Run it by the following command: javac -processor index cast_unsafe.java

Output:

cast_unsafe.java:4: warning: [cast.unsafe] "@DoubleVal(0.75) float" may not be casted to the type "@IntVal(0) int"
    	int c = (int)(b);
    	        ^
cast_unsafe.java:4: warning: [cast.unsafe] "@LowerBoundUnknown float" may not be casted to the type "@NonNegative int"
    	int c = (int)(b);
    	        ^
2 warnings

However, the cast is safe and c evaluates to 0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions