Compiler bug or gray area in C?

When a problem comes along . . . you must whip it daveb at ingres.com
Thu Nov 29 09:02:33 AEST 1990


Given this simplification:
	
	extern	double D, foo();
	
	foo( i )
	int i;
	{
		double	x;
		int	changes = 0;
		do {
	
			x = foo( i );
	
			if( x < D )
			{
				changed++;
				D = x;
			}
	
		} while( !changed );	
	}

is it reasonable for this to not terminate?

We see a number of compilers that keep x in a register with extended
precision, so that it has bits that are not in the global D.  Thus, the
comparison (x < D) fails, even after D is assigned the value of x.  

Yes, floating point in C is peculiar, but is it _this_ peculiar?

thanks,
-dB
--
"If it were easy to understand, we wouldn't call it 'code'"
David Brower: {amdahl, cpsc6a, mtxinu, sun}!rtech!daveb daveb at ingres.com



More information about the Comp.lang.c mailing list