[Info-vax] decrementing & for loops in C
Bill Gunshannon
billg999 at cs.uofs.edu
Thu Jan 8 09:52:53 EST 2009
In article <gk534r$677$1 at south.jnrs.ja.net>,
"Richard Brodie" <R.Brodie at rl.ac.uk> writes:
>
> <johnwallace4 at yahoo.co.uk> wrote in message news:09411eb9-a739-4e87-9278-
>
>> Some kinder compilers will (optionally) offer a warning when an
>> assignment rather than a logical expression is used in this context.
>
> /warn=enable=questcode is a reasonable balance between passing
> probable errors silently.
The original code is not "questionable", it is 100% correct. And,
as I stated elsewhere, a really good optimizing compiler, after
examining the assembler generated by that piece of code would find
that it was always successful and would optimize the loop out
completely.
>
> C minimalists will argue that the correct way to write 'i != 0' is 'i'.
I have been doing C for almost 30 years and even I would not do that,
specifically, for stylistic reasons. Not every C programmer writes
his code so that it can't be maintained.
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