From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.5 required=3.0 tests=BAYES_05 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: Sat, 12 Dec 1992 10:39:14 -0600 (CST) From: PETCHER@OTTAWA.dseg.ti.com (What? Me Ada?) Subject: Language wars Message-ID: <921212103914.20203764@OTTAWA.DSEG.TI.COM> List-Id: Furgus Henderson posts: >mfeldman@seas.gwu.edu (Michael Feldman) writes: >>You make a good point. Perhaps the modern equivalent of that Fortran >>single-keystroke bug is my favorite bit of C code (and no, I don't >>want to bash C, just point out how common these flukes are): >> >> int x; >> ... >> x = 1; >> while (x <= 10); >> { >> printf("%d\n", x); >> x++; >> } >A good compiler would give a warning that the call to printf was >unreachable code. The only compiler I have available, gcc, unfortunately >doesn't give any such warning. But the Pascal-subset compiler I wrote (as one >of the projects for a 3rd-year subject) gives the following warnings for >the equivalent Pascal code: >warning: variable 'x' is not used after assignment, so assignment has no effec t >warning: 'while' statement will cause an infinite loop I would submit that neither of these warnings is completely correct for this particular example, at least without further qualification. 'x' is, in fact, used after assignment, although both the assignment and the subsequent use could be optimized away. If they are, the compiler should state that in the warning. If not, no warning should be given. If you really put the offending semicolon in by accident, but the program compiled OK anyway, even with the warning, you'd say "Of course it's used. Compiler bug." then get in there with a debugger and wonder why you couldn't find 'x' or any code associated with it. The warning about the infinite loop should only be given if the compiler supports the "volatile" storage class modifier. Most do, and I think the ANSI standard requires it, but not all compilers support it just the same, or just ignore it. The result is something outside the current context could change the value of x and terminate the loop. On the life cycle cost controversy: While, as somebody recently pointed out, statistics can be cooked up any way you want them, even a good cook can't cook without ingredients. The typical life cycle of a military system is about 20 years, probably to grow a bit as time goes on. I'm not sure what the oldest fielded Ada based system is right now, but it couldn't be over four or five years old. Anybody who attempts to compare life cycle cost can only do so based on speculation. ---------------------------------------------------------------------------- | Malcolm Petcher | Coming soon to this location: | | Petcher@m2000.dseg.ti.com | some fancy disclaimer that keeps | | Malcolm Petcher @ V'ger | me from getting fired | ----------------------------------------------------------------------------