Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!dog.ee.lbl.gov!elf.ee.lbl.gov!torek From: torek@elf.ee.lbl.gov (Chris Torek) Newsgroups: comp.lang.c Subject: Re: When do you use "if ( a = b )"? (was Re: Funny mistake) Message-ID: <11204@dog.ee.lbl.gov> Date: 20 Mar 91 21:45:46 GMT References: <8148@rsiatl.Dixie.Com> <15481@smoke.brl.mil> <775@camco.Celestial.COM> <65837@eerie.acsu.Buffalo.EDU> <1991Mar18.195351.11985@unlv.edu> <11109@dog.ee.lbl.gov> Reply-To: torek@elf.ee.lbl.gov (Chris Torek) Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 15 X-Local-Date: Wed, 20 Mar 91 13:45:47 PST In article av@uta.fi (Arto Viitanen) writes: [gcc version 1.39 on Sun-3, compiling `if (a = b)' vs `a = b; if (a)'] >In GNU cc, it was other way round: without optimization, assembler code >was same, but with optimization, they were different. That is peculiar. I tried the same thing, with the same gcc, on the same machine, and got identical code when optimized, different (poorer) code for the second when not, exactly as expected. (gcc without -O typically produces truly awful code: the compiler relies quite heavily on optimization to clean up after the initial code generation. This is reasonable, but does mean that you probably never should compile without -O unless you are trying to debug the compiler itself.) -- In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 415 486 5427) Berkeley, CA Domain: torek@ee.lbl.gov