Subject: Bug in gcc
To: None <macbsd-general@sun-lamp.cs.berkeley.edu>
From: Ross Williamson <rossw@ccu1.auckland.ac.nz>
List: macbsd-general
Date: 12/11/1993 18:11:44
Here's a little bug in ggc I've come across try the following code


#include <stdio.h>
#include <math.h>

main()
{
	int i;
	double c;

	for ( i = 0 ; i< 5 ; i++ )
	{
		c = exp( -i / 900.0 );
		printf("%d : %10.4lf\n" , i , c );
	}
}


now we expect this to give this sort of out put
0 : 1.0000
1 : 0.9998
2 : 0.9997

etc...

however if you try it you'll find that you get a segmentation fault.
It's due to the case when i ==0.  It tries to evaluate exp(-0/900.0).
Sounds silly ( I know it took me about 6 hours to find the bug in
approx 25,000 lines of code :( ) but it's there can anyone else
duplicate it?

----
Ross Williamson
rossw@ccu1.auckland.ac.nz
Auckland University, New Zealand
Of course these opinions are my own and thank <!!> for that
                               ----
        Once upon a time, in a little directory, there was a bug.
        A big, bad, evil bug.  But then one day, the mighty programmer
        came and slew it, and there was much rejoicing.


------------------------------------------------------------------------------