help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[about optimization]Is this a bug of gcc?


From: mojianhao
Subject: [about optimization]Is this a bug of gcc?
Date: Fri, 15 Feb 2008 20:05:06 +0800


Hi experts,     I have a small test case, it got different result when compile 
with -O0 option and -O2 option. Is this a bug of gcc 
?===============================test.c===============================#include 
<stdio.h>void test(double a){  double b;  b = a * 100000.00000000000;  if(a<0)  
  printf("a<0\n");  else if(b == 19753086420000.0000000000)  {    a += 
0.000005;    printf("a+=0.000005\n");  }  printf("a=%f\n",a);}int main(){  
double a=987654321/5.0;  
test(a);}===========================================================result:=============================$
 gcc -O0 test.c$ ./a.outa+=0.000005a=197530864.200005$ gcc -O2 test.c$ 
./a.outa=197530864.200000==========================================================
my gcc version:
=============================
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man 
--infodir=/usr/share/info 
--enable-shared --enable-threads=posix --disable-checking --with-system-zlib 
--enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk 
--host=i386-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 
=============================
Regards,Jianhao Mo
_________________________________________________________________
MSN圣诞礼物火热登场,免费发放中,快来领取吧!
http://im.live.cn/emoticons/?ID=18




reply via email to

[Prev in Thread] Current Thread [Next in Thread]