Community
Participate
Working Groups
(This is a feature request, not a bug) As stated in the Java Language Specification (http://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.26.2) a compound assignment operator (e.g. +=, -=…) does an implicit cast to the type of the variable the value is assigned to. This is potentially not obvious to the programmer (it wasn't to me) and can cause bizarre bugs. Quote from the link above: For example, the following code is correct: short x = 3; x += 4.6; and results in x having the value 7 because it is equivalent to: short x = 3; x = (short)(x + 4.6); It would be nice if eclipse would issue a warning on the line "x += 4.6", i.e. if it detects that an implicit cast (caused by using a compound assignment operator) could result in loss of precision. Build Identifier: 20130614-0229