c2 (c optimizer) bug

utzoo!decvax!harpo!seismo!dmy utzoo!decvax!harpo!seismo!dmy
Tue Dec 14 16:48:43 AEST 1982


/*
   The following program contains, as one line, the smallest version of a
   c-optimizer bug that I could construct.  I looked at the erroneous assembler
   code produced by the optimizer, and this is definitely a compiler problem.
   Anyone know of this bug before?

   On our 4.1absd, running a.out after cc -O test.c produces 840.
   After cc test.c, it produces the correct value of 50.

   The bug (in the optimized object code) is a missing cvtdl (I believe).
*/

main()
{
float f;
int n;
	f = 50.0;
	n = (int)f & 07777;	/* this statement is the bug */
	printf("%d\n",n);
}


/*

--dmy--

*/



More information about the Comp.lang.c mailing list