For statement not portable? (was: What does Z["ack"] = 5 mean?)

Guy Harris guy at auspex.UUCP
Thu Oct 20 02:34:27 AEST 1988


>|It is also possible that compiler writers will get the "for" loop
>|handling wrong.  It is unwise to depend on "for" loops in portable
>|code.  Use a "while" loop instead.
>
>The semantics of the "for" statement seem pretty clear, though (see
>K&R Appendix A, 9.6 & 9.8, 9.9). Could you be a bit more specific about
>how they get it wrong? I didn't see any compilers broken in this respect
>yet. If there are any, they would break a lot of existing code.

Gee, I thought the comment about the "for" loop was rhetorical, inserted
only to indicate that if you decide to avoid using legal C constructs
(and subscripting an integer by an array most definitely *is* legal)
because some implementor might get them wrong, there's no clear place to
stop - hey, if they don't treat "a[b]" as "*(a + b)" as they're supposed
to, they might get "for" wrong, and then they might even get "while"
wrong too.  I didn't think it was referring to some known problem. 



More information about the Comp.lang.c mailing list