Broken compilers? (was Re: Comma Operator)

Tim Olson tim at crackle.amd.com
Tue Jan 17 09:01:57 AEST 1989


In article <1907 at buengc.BU.EDU> bph at buengc.bu.edu (Blair P. Houghton) writes:
| Of course, if the side-effect of such a "dead" thing was that your PDP-8's
| eleventeenth-bit-light blinked, and that bulb was removed and the electrical
| contacts hooked to your Mr. Coffee controller, and your new artificially-
| intelligent compiler reduced the expression and unwittingly eliminated the
| blink, and you failed the CS 101 exam because of caffeine withdrawal...

Nah, just remember to declare it "volatile":

	volatile int PDP_11th_light_kludged_into_Mr_Coffee_Machine;

;-)

Dead code elimination does have other useful benefits.  I was looking
over some assembly code generated by the MetaWare Am29000 C compiler
from proprietary sources that a large company had given us, and was able
to catch the error in the following code, because the compiler generated
no instructions for it other than the return!

foo(myColor, index)
RGB *myColor;
long *index;
{
	if ((myColor->red + myColor->green + myColor->blue)/3 <= (MAXRGB/2))
		*index++;
}


	-- Tim Olson
	Advanced Micro Devices
	(tim at crackle.amd.com)



More information about the Comp.lang.c mailing list