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

Arto V. Viitanen av at kielo.uta.fi
Wed Mar 20 16:47:24 AEST 1991


>>>>> On 19 Mar 91 19:13:45 GMT, torek at elf.ee.lbl.gov (Chris Torek) said:
Chris> X-Local-Date: Tue, 19 Mar 91 11:13:46 PST

Chris> In article <1991Mar18.195351.11985 at unlv.edu> grover at sonny-boy.cs.unlv.edu
Chirs> ---well, if
Chris> your compiler generates different code for

Chris> 	if (a = b)

Chris> than for

Chris> 	a = b;
Chris> 	if (a)

Chris> then your compiler is not worth what you paid for it. 

I checked those differences with SUN's cc (SUN3/SunOs 4.0.3) and GNU cc
(version 1.39) In SUN's cc there was differences when optimization was turned
off; they generated same assembler code whith optimization. In GNU cc, it was
other way round: without optimization, assembler code was same, but with
optimization, they were different.

I think GNU cc is still worth it price !!

Chris> In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 415 486 5427)
Chris> Berkeley, CA		Domain:	torek at ee.lbl.gov

--
Arto V. Viitanen				         email: av at kielo.uta.fi
University Of Tampere,				   	    av at ohdake.cs.uta.fi
Finland



More information about the Comp.lang.c mailing list