This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/28144] New: floating point constant -> byte/char/short conversion is wrong for java
- From: "amylaar at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Jun 2006 16:40:31 -0000
- Subject: [Bug tree-optimization/28144] New: floating point constant -> byte/char/short conversion is wrong for java
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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