According to:
http://java.sun.com/docs/books/jls/second_edition/html/conversions.doc.html#25363

java conversions of floating point values to integer types smaller than int
should be done by converting to integer first, and then from int to the target
type.  While the former conversion is done with saturation, the latter is
done by discarding the most significant bits.
i.e. 65536.0 converted to char is 0 .

However, fold_convert_const_int_from_real will compute 65535 instead.


-- 
           Summary: floating point constant -> byte/char/short conversion is
                    wrong for java
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: amylaar at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28144

Reply via email to