This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
typecasting error in gcc (GCC) 3.2.2
- From: "Gautham S. Chundi" <gautham at aquarius dot as dot arizona dot edu>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 25 Jan 2003 18:02:08 -0700 (MST)
- Subject: typecasting error in gcc (GCC) 3.2.2
Hi,
Bug report on :
gcc (GCC) 3.2.2 20030124 (Debian prerelease)
This is an error in the typecasting operation.
the two operations I'm performing are supposed to give me the same answer
on this version of gcc but seems to work fine on gcc 3.0 on an IRIX
machine.
This seems to be an X86 specific bug because ver 2.95 also did this.
This is what I did :
gcc -Wall test1.c -o test1 -lm
this is the program I ran to compare results :
#include <math.h>
#include <stdio.h>
int main()
{
int i,temp;
double y;
i=8;
temp=(int)(log(i)/log(2.0));
y=log(i)/log(2.0);
printf("\ntemp = %d y = %d\n",temp,(int)y);
return(0);
}
both temp, and y should be 3 (I came across this trying to emulate a
log2() operation,but I get temp=2 and (int)y= 3 ...
-gautham
------------------------------------------------------------------------------
Gautham S. Chundi
Graduate Research Assistant 901,N.1st Ave.
Center for Astronomical Adaptive Optics Apt # 14
N402,Steward Observatory Tucson,AZ 85719
University of Arizona,Tucson (520) 670-1768
(520) 621-1624