Bug#164135: gcc bug?: sin(a) * sin(b) gives wrong result
Package: gcc-3.0
Version: 1:3.0.4-7
Kernel: self-compiled 2.4.18
libc6: 2.2.5-11.2
libc6-dev: 2.2.5-11.2
System: woody on a Pentium 4 with 2 GHz and 1 GB RAM
It looks to me as if gcc can't parse the following line correctly:
double c=sin(a) * sin(b);
Excuse me if this is just a stupid programming error of my part, I'm not
an experienced C programmer.
I compiled the following little programm:
#include <stdlib.h>
#include <tgmath.h>
int main ()
{
const double a=-0.591084;
const double b=0.618719;
double res=sin(a) * sin(b);
printf ("one step: %f\n", res);
res=(sin(a)) * (sin(b));
printf ("one step: %f\n", res);
double sina=sin(a);
double sinb=sin(b);
res=sina * sinb;
printf ("two steps: %f\n", res);
exit(0);
}
with gcc-3.0 -lm -o parsbug parsbug
and it gives me the following output:
one step: 0.336391
one step: 0.336391
two steps: -0.323207
Only the last line is correct.
By the way, gcc-2.95 always gives me a lot of parse errors and doesn't compile this at all.
Cheers
Khalid
--
###############################################################################
#
#
# La traditionelle lucidité des dépressifs, souvent décrite comme un
#
# désinvestissement radical à l'égard des préoccupations humaines, se
#
# manifeste en tout premier lieu par un manque d'intérêt pour les
questions #
# effectivement peu intéressantes. Ainsi peut-on, à la rigueur, imaginer
un #
# dépressif amoureux, tandis qu'un dépressif patriote paraît franchement
#
# inconcevable.
#
# (M. Houellebecq: Les particules élémentaires)
#
#
#
###############################################################################
Reply to: