[Info-vax] decrementing & for loops in C

Bill Gunshannon billg999 at cs.uofs.edu
Thu Jan 8 11:01:13 EST 2009


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.

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