Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* Bug in C compiler?
@ 1996-09-19  4:00 Theo Vosse
  1996-09-19  4:00 ` Ron Natalie
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Theo Vosse @ 1996-09-19  4:00 UTC (permalink / 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



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1996-09-20  4:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-09-19  4:00 Bug in C compiler? Theo Vosse
1996-09-19  4:00 ` Ron Natalie
1996-09-19  4:00   ` Ron Natalie
1996-09-19  4:00 ` Stephen Hoff Hoffman
1996-09-20  4:00 ` Theo Vosse
1996-09-20  4:00 ` Phil Ottewell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox