comp.lang.ada
 help / color / mirror / Atom feed
* Do compilers generate enough warnings ?
@ 1994-11-08 21:04 Peter Burwood
  0 siblings, 0 replies; only message in thread
From: Peter Burwood @ 1994-11-08 21:04 UTC (permalink / raw)


We had a small error in some code last week and I was suprised that neither
of the compilers we used raised a warning that either a constraint error
would be raised at run time or the use of an uninitialised variable.

I know the program is erroneous (and hence no exception is guaranteed), but
here is the general gist of it ...

package body Foo is
...
   type Elements is array ( Elements_Range ) of Element;

   procedure Bar ( Elems : in Elements ) is
      Index   : Elements_Range;
      Elem    : Element renames Elems ( Index );
   begin
      -- use of Elem in here is erroneous
   end Bar;
...
end foo;

Stupid syntax errors disregarded, there is an obvious error with the
'renames' statement. Now the person who wrote this code has > seven years
experience in Ada and spotted the mistake immediately when it was pointed
out. The bug was introduced by simple mistake. (Okay, hopefully I've covered
their blushes now!).

Does it seem unreasonable for a compiler to raise a warning about the use of
an uninitiased variable with the above code ?

Upon executing the program, one compiler raised an exception error (hidden
inside a task, and only happened after a two hour run on one particular set
of data) and the other compiler continued on oblivious (who knows what got
scribbled on).

I guess we were lucky that an exception error got raised, it could have been
a horribly nasty bug to track down otherwise considering the size of the
application and the time the program ran before hitting this code.

regards,
Pete
-- Email: pjb@arcangel.demon.co.uk



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1994-11-08 21:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1994-11-08 21:04 Do compilers generate enough warnings ? Peter Burwood

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