'386 XENIX "cc -Ox" optimization bug

Jon Boede jon at ccwf.cc.utexas.edu
Sat Dec 8 09:22:13 AEST 1990


Hopefully I'm posting old news... but I found a rather insidious bug in cc
version 1.6.  It seems that if you use the -Oa "ignore aliasing" option with
the -Ol "enable loop optimizations" option, it starts thinking deciding that
more things are loop invariants than really are!  The seductively named -Ox
"max. optimization" option implies -Oal.

Try: cc x.c; a.out; cc -Ox x.c; a.out; cc -Oal x.c; a.out

----- cut here -- x.c
main()
{
	int value;

	value = 1;
	printf("1. value is %d\n",value);

	do {
		printf("2. value is %d\n",value);
		puts(value ? "works ok" : "your compiler is broke");
		value = 0;
	} while (false());
}

false()
{
	return(0);
}
----- ereh tuc

It's a little bothersome to turn on "max. optimization" and have your code stop
working! ;-)

Jon
-- 
Jon Boede    jon at bodedo.ucm.org  ...!{the-world}!uunet!cs.utexas.edu!bodedo!jon
7117 Wood Hollow #1013, People's Republic of Austin, TX  78731  +1 512 346-3142



More information about the Comp.lang.c mailing list