From: vosse@ruls41.fsw.LeidenUniv.nl (Theo Vosse)
Subject: Bug in C compiler?
Date: 1996/09/19 [thread overview]
Message-ID: <4buf2zhlw.fsf@ruls41.fsw.LeidenUniv.nl> (raw)
Hi,
I wrote this piece of program:
static double FillBinomTable(double tab[], int b)
{
double factor = 1.0 / pow(2.0, b);
int n = b, m = 1;
int i = 0;
while (n != -1)
{
tab[i++] = factor;
factor *= (double) n-- / (double) m++;
}
}
which fills a table with binomial probabilities. The problem is that
when I use DEC's c compiler (with -g), 'factor' becomes 0.707106...,
which is sqrt(2), whereas when I use gcc, it becomes 1/(2**b). The
last one is correct.
Is this some kind of optimizer bug?
Theo Vosse
----------
Unit for Experimental Psychology
University of Leiden
The Netherlands
--
Theo Vosse
----------
Unit for Experimental Psychology
University of Leiden
The Netherlands
next reply other threads:[~1996-09-19 4:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-09-19 4:00 Theo Vosse [this message]
1996-09-19 4:00 ` Bug in C compiler? Stephen Hoff Hoffman
1996-09-19 4:00 ` Ron Natalie
1996-09-19 4:00 ` Ron Natalie
1996-09-20 4:00 ` Theo Vosse
1996-09-20 4:00 ` Phil Ottewell
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox