From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,4f7a405235f760ec,start X-Google-Attributes: gid1164f8,public From: vosse@ruls41.fsw.LeidenUniv.nl (Theo Vosse) Subject: Bug in C compiler? Date: 1996/09/19 Message-ID: <4buf2zhlw.fsf@ruls41.fsw.LeidenUniv.nl>#1/1 X-Deja-AN: 183947624 organization: Leiden University newsgroups: comp.sys.dec 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