[Info-vax] decrementing & for loops in C
Bill Gunshannon
billg999 at cs.uofs.edu
Thu Jan 8 14:00:16 EST 2009
In article <gk5gsk$q46$1 at usenet01.boi.hp.com>,
"Ed Vogel" <edward.vogel at hp_stopping_spam.com> writes:
>
> "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 day we can truly trust the computer to understand what we meant
rather than what we said I will be very afraid. :-)
>
> The purpose of /warn=enable=questcode is to detect such
> cases.
I prefer relying on code reviews by humans.
>
>>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.
>
Knowing the skill level of the compiler writers there I would have
been very surprised if it didn't.
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