From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31880 invoked by alias); 15 Jan 2003 12:16:04 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 31850 invoked by uid 71); 15 Jan 2003 12:16:01 -0000 Resent-Date: 15 Jan 2003 12:16:01 -0000 Resent-Message-ID: <20030115121601.31849.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, kcc@mcst.ru Received: (qmail 31068 invoked by uid 61); 15 Jan 2003 12:11:10 -0000 Message-Id: <20030115121110.31067.qmail@sources.redhat.com> Date: Wed, 15 Jan 2003 12:16:00 -0000 From: kcc@mcst.ru Reply-To: kcc@mcst.ru To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: optimization/9325: wrong conversion of constants: (int)(float)(int) (INT_MAX) X-SW-Source: 2003-01/txt/msg00941.txt.bz2 List-Id: >Number: 9325 >Category: optimization >Synopsis: wrong conversion of constants: (int)(float)(int) (INT_MAX) >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Wed Jan 15 04:16:01 PST 2003 >Closed-Date: >Last-Modified: >Originator: Konstantine Serebriany >Release: 3.2 >Organization: >Environment: Sparc Solaris 2.8 >Description: (int)(float)(int)(INT_MAX) is transformed to INT_MAX, which is incorrect. Should leave the conversions. f1() and f2() are optimized wrong, while f3() and f4() are ok ///// file 2_31.c extern int printf(const char *, ...); int f1(){ return (int)2147483648.0f; } int f2(){ return (int)(float)( 2147483647 ); } int f3(){ float a = 2147483648.0f; return (int)a; } int f4(){ int a = 2147483647; float b = (float)a; return (int)b; } int main() { printf("%d\n%d\n%d\n%d\n", f1(), f2(), f3(), f4()); return 0; } >How-To-Repeat: gcc 2_31.c ; a.out >Fix: >Release-Note: >Audit-Trail: >Unformatted: