From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6916 invoked by alias); 23 Jun 2006 16:40:38 -0000 Received: (qmail 6841 invoked by uid 48); 23 Jun 2006 16:40:31 -0000 Date: Fri, 23 Jun 2006 16:44:00 -0000 Subject: [Bug tree-optimization/28144] New: floating point constant -> byte/char/short conversion is wrong for java X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "amylaar at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-06/txt/msg02151.txt.bz2 List-Id: 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