From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18327 invoked by alias); 16 May 2003 18:36:03 -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 18281 invoked by uid 71); 16 May 2003 18:36:02 -0000 Resent-Date: 16 May 2003 18:36:02 -0000 Resent-Message-ID: <20030516183602.18280.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, guindon@lirmm.fr Resent-Reply-To: gcc-gnats@gcc.gnu.org, lethiec@lirmm.fr Received: (qmail 13041 invoked by uid 48); 16 May 2003 18:32:17 -0000 Message-Id: <20030516183217.13040.qmail@sources.redhat.com> Date: Fri, 16 May 2003 18:36:00 -0000 From: lethiec@lirmm.fr Reply-To: lethiec@lirmm.fr To: gcc-gnats@gcc.gnu.org Cc: guindon@lirmm.fr X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) X-GNATS-Notify: guindon@lirmm.fr Subject: optimization/10825: GCC 2.3.2 cannot compare two double X-SW-Source: 2003-05/txt/msg01872.txt.bz2 List-Id: >Number: 10825 >Category: optimization >Synopsis: GCC 2.3.2 cannot compare two double >Confidential: no >Severity: critical >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Fri May 16 18:36:02 UTC 2003 >Closed-Date: >Last-Modified: >Originator: Franck Le Thiec >Release: 3.2.3 >Organization: >Environment: i386-linux 2.4.17 >Description: in a loop a multiple of M_PI is put into two variables, one is an array of double allocated by malloc the other is a double. they compare equal when using gcc with options "-lm" or "-O1 -lm" they compare different when using gcc with "-O2 -lm" or "-O3 -lm" or "-O4 -lm" >How-To-Repeat: #include #include #include int main(int argc, char **argv) { double *a1,a2; int i; a1 = (double*)malloc(sizeof(double)); a1[0]=a2=0.0; for(i=1;i<15;i++) { /*if we loop until 13 no problem!*/ a1[0] += M_PI; a2 += M_PI; } printf("%.50f\n%.50f\n",a1[0], a2); if (a1[0]==a2) printf("equal\n"); else printf("different\n"); free(a1); } >Fix: no known fixes ! >Release-Note: >Audit-Trail: >Unformatted: