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

Leo de Wit leo at philmds.UUCP
Tue Oct 18 05:47:31 AEST 1988


In article <6945 at cdis-1.uucp> tanner at cdis-1.uucp (Dr. T. Andrews) writes:
|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.

And then, what standards are we going to support? Those imposed by
generally accepted documents, or those thrusted upon you by faulty
compilers?  If it's going to be the latter, you must already be very
sure about how well each and every compiler generates code for each and
every C construct.  Apart from the fact that this seems hardly doable,
one wonders now what other constructs are potentially hazardous...

And I liked the for statement so well (and I'm not yet convinced).

           Leo.
                           for ( t; r; a) n;



More information about the Comp.lang.c mailing list