[Info-vax] decrementing & for loops in C

Bill Gunshannon billg999 at cs.uofs.edu
Thu Jan 8 11:32:24 EST 2009


In article <176uZD2KcidF-pn2-n85UEkyTHLOR at rikki.tavi.co.uk>,
	"Bob Eager" <rde42 at spamcop.net> writes:
> On Thu, 8 Jan 2009 16:01:13 UTC, billg999 at cs.uofs.edu (Bill Gunshannon) 
> wrote:
> 
>> In article <6sml69F71m8lU1 at mid.individual.net>,
>> 	billg999 at cs.uofs.edu (Bill Gunshannon) writes:
>> >
>> >                                Maybe I will try some of the compilers I
>> > have to see if one of them actually does it.
>> 
>> OK, I tried it with GCC on x86.  I tried using both "=" and "=="
>> with and without the "-O" option.
>> 
>> Results:
>> 
>> == & no optimization:  Loop is there but condition to execute loop never
>>                        exists.
>> 
>> = & no optimization:   Loop code not even generated.
>> 
>> == & "-O":  Loop code including loop setup optimized out of code.
>> 
>> = & "-O":  Loop code including loop setup optimized out of code.
>> 
>> So, GCC at least can tell the logic does not allow for execution of the
>> loop and takes the appropriate action.  Sadly, it does not contain code
>> the cause the computer to reach out and slap the programmer on the back
>> of the head.
> 
> Try using:      gcc -Wparentheses ...

That option causes no change in the generated assembler source.
What is it supposed to do?  It looks like it would warn about
unmatche parentheses, which is not a problem in this program.
(I am not well versed on all the wacky crap that GNU thought
compilers should have.)

bill
 

-- 
Bill Gunshannon          |  de-moc-ra-cy (di mok' ra see) n.  Three wolves
billg999 at cs.scranton.edu |  and a sheep voting on what's for dinner.
University of Scranton   |
Scranton, Pennsylvania   |         #include <std.disclaimer.h>   



More information about the Info-vax mailing list