[Info-vax] decrementing & for loops in C
Ed Vogel
edward.vogel at hp_stopping_spam.com
Thu Jan 8 13:32:50 EST 2009
"Bill Gunshannon" <billg999 at cs.uofs.edu> wrote in message
news:6smia4F73tecU6 at mid.individual.net...
> 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.
This depends upon what you mean by "correct". Sure, it's
valid syntax, but it may not do what the user intended.
The purpose of /warn=enable=questcode is to detect such
cases.
>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.
I believe the HP C compiler for OpenVMS detects this and will
generate no code for the loop.
Ed Vogel
HP/Compaq/DEC C/C++ Engineering
More information about the Info-vax
mailing list