typecasting error in gcc (GCC) 3.2.2
Gautham S. Chundi
gautham@aquarius.as.arizona.edu
Sun Jan 26 09:03:00 GMT 2003
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
More information about the Gcc-bugs
mailing list