[Info-vax] decrementing & for loops in C
Bob Eager
rde42 at spamcop.net
Thu Jan 8 12:27:35 EST 2009
On Thu, 8 Jan 2009 16:32:24 UTC, billg999 at cs.uofs.edu (Bill Gunshannon)
wrote:
> 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.)
If there is an assignment within the for() condition, it will warn about
it.
--
Bob Eager
More information about the Info-vax
mailing list