When do you use "if ( a = b )"? (was Re: Funny mistake)

Chris Torek torek at elf.ee.lbl.gov
Wed Mar 20 05:13:45 AEST 1991


In article <1991Mar18.195351.11985 at unlv.edu> grover at sonny-boy.cs.unlv.edu
(Kevin Grover) writes:
>There are plenty of uses for it.  It will allow smaller code, and checks to be
>done quicker.

Smaller source code, yes.  Smaller or faster object code---well, if
your compiler generates different code for

	if (a = b)

than for

	a = b;
	if (a)

then your compiler is not worth what you paid for it.  (Well, with two
possible exceptions: if you have turned off all optimization, or if `a'
is declared `volatile'.)
-- 
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 415 486 5427)
Berkeley, CA		Domain:	torek at ee.lbl.gov



More information about the Comp.lang.c mailing list