home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ornl!utkcs2!darwin.sura.net!udel!wupost!spool.mu.edu!agate!ucbvax!OTTAWA.dseg.ti.com!PETCHER
- From: PETCHER@OTTAWA.dseg.ti.com (What? Me Ada?)
- Newsgroups: comp.lang.ada
- Subject: Language wars
- Message-ID: <921212103914.20203764@OTTAWA.DSEG.TI.COM>
- Date: 12 Dec 92 16:39:14 GMT
- Sender: usenet@ucbvax.BERKELEY.EDU
- Organization: The Internet
- Lines: 52
-
- 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 effect
- >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 |
- ----------------------------------------------------------------------------
-