public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/28144]  New: floating point constant -> byte/char/short conversion is wrong for java
@ 2006-06-23 16:44 amylaar at gcc dot gnu dot org
  2006-06-23 18:00 ` [Bug tree-optimization/28144] " amylaar at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: amylaar at gcc dot gnu dot org @ 2006-06-23 16:44 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-07-17 16:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-23 16:44 [Bug tree-optimization/28144] New: floating point constant -> byte/char/short conversion is wrong for java amylaar at gcc dot gnu dot org
2006-06-23 18:00 ` [Bug tree-optimization/28144] " amylaar at gcc dot gnu dot org
2006-06-26 11:19 ` aph at gcc dot gnu dot org
2006-06-26 12:27 ` joern dot rennecke at st dot com
2006-06-29 21:45 ` patchapp at dberlin dot org
2006-07-17 16:05 ` patchapp at dberlin dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).