home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / ada / 3644 < prev    next >
Encoding:
Internet Message Format  |  1992-12-13  |  3.0 KB

  1. Path: sparky!uunet!ornl!utkcs2!darwin.sura.net!udel!wupost!spool.mu.edu!agate!ucbvax!OTTAWA.dseg.ti.com!PETCHER
  2. From: PETCHER@OTTAWA.dseg.ti.com (What? Me Ada?)
  3. Newsgroups: comp.lang.ada
  4. Subject: Language wars
  5. Message-ID: <921212103914.20203764@OTTAWA.DSEG.TI.COM>
  6. Date: 12 Dec 92 16:39:14 GMT
  7. Sender: usenet@ucbvax.BERKELEY.EDU
  8. Organization: The Internet
  9. Lines: 52
  10.  
  11. Furgus Henderson posts:
  12. >mfeldman@seas.gwu.edu (Michael Feldman) writes:
  13.  
  14. >>You make a good point. Perhaps the modern equivalent of that Fortran
  15. >>single-keystroke bug is my favorite bit of C code (and no, I don't
  16. >>want to bash C, just point out how common these flukes are):
  17. >>
  18. >>   int x;
  19. >>   ...
  20. >>   x = 1;
  21. >>   while (x <= 10);
  22. >>   {
  23. >>      printf("%d\n", x);
  24. >>      x++;
  25. >>   }
  26.  
  27. >A good compiler would give a warning that the call to printf was
  28. >unreachable code. The only compiler I have available, gcc, unfortunately
  29. >doesn't give any such warning. But the Pascal-subset compiler I wrote (as one
  30. >of the projects for a 3rd-year subject) gives the following warnings for
  31. >the equivalent Pascal code:
  32.  
  33. >warning: variable 'x' is not used after assignment, so assignment has no effect
  34. >warning: 'while' statement will cause an infinite loop
  35.  
  36. I would submit that neither of these warnings is completely correct for this
  37. particular example, at least without further qualification.  'x' is, in fact,
  38. used after assignment, although both the assignment and the subsequent use
  39. could be optimized away.  If they are, the compiler should state that in the
  40. warning.  If not, no warning should be given.  If you really put the
  41. offending semicolon in by accident, but the program compiled OK anyway, even
  42. with the warning, you'd say "Of course it's used.  Compiler bug." then get in
  43. there with a debugger and wonder why you couldn't find 'x' or any code
  44. associated with it.  The warning about the infinite loop should only be given
  45. if the compiler supports the "volatile" storage class modifier.  Most do, and
  46. I think the ANSI standard requires it, but not all compilers support it just
  47. the same, or just ignore it.  The result is something outside the current
  48. context could change the value of x and terminate the loop.
  49.  
  50. On the life cycle cost controversy:  While, as somebody recently pointed out,
  51. statistics can be cooked up any way you want them, even a good cook can't
  52. cook without ingredients.  The typical life cycle of a military system is
  53. about 20 years, probably to grow a bit as time goes on.  I'm not sure what
  54. the oldest fielded Ada based system is right now, but it couldn't be over
  55. four or five years old.  Anybody who attempts to compare life cycle cost can
  56. only do so based on speculation.
  57.  
  58. ----------------------------------------------------------------------------
  59. | Malcolm Petcher                    | Coming soon to this location:       |
  60. | Petcher@m2000.dseg.ti.com          | some fancy disclaimer that keeps    |
  61. | Malcolm Petcher @ V'ger            | me from getting fired               |
  62. ----------------------------------------------------------------------------
  63.