optimazion bug in C compiler on SS1+?
Steven Janowsky
janowsky at math.rutgers.edu
Tue Mar 12 06:31:40 AEST 1991
The following program (part of a random number generator) generates NaN
when compiled O2, O3, or O4 but works as expected if O1 or no optimiztion.
SS1+ running 4.0.3c
Any clues? (Please mail response to janowsky at hilbert.rutgers.edu)
#include <stdio.h>
main()
{
int seed;
double rand_a, rand_t;
seed = 34;
rand_a= -1.0 + 1.0 / 2147483648.0;
rand_t=seed/2147483648.0;
printf("%g\n",rand_t);
rand_t *= 16807;
rand_t += rand_a * ((int) rand_t);
if(rand_t >= 1.0) rand_t += rand_a;
printf("%g\n",rand_t);
}
More information about the Comp.unix.wizards
mailing list