comp.lang.ada
 help / color / mirror / Atom feed
From: PETCHER@OTTAWA.dseg.ti.com (What? Me Ada?)
Subject: Language wars
Date: Sat, 12 Dec 1992 10:39:14 -0600 (CST)	[thread overview]
Message-ID: <921212103914.20203764@OTTAWA.DSEG.TI.COM> (raw)

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               |
----------------------------------------------------------------------------

             reply	other threads:[~1992-12-12 16:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-12-12 16:39 What? Me Ada? [this message]
  -- strict thread matches above, loose matches on Subject: below --
1996-09-05  0:00 Language Wars Roy Gardiner
1996-09-05  0:00 ` Jay McFadyen
1996-09-05  0:00   ` Dave Jones
1996-09-06  0:00     ` Larry Kilgallen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox