comp.lang.ada
 help / color / mirror / Atom feed
From: pjb@arcangel.demon.co.uk (Peter Burwood)
Subject: Do compilers generate enough warnings ?
Date: Tue, 8 Nov 1994 21:04:18 GMT
Date: 1994-11-08T21:04:18+00:00	[thread overview]
Message-ID: <19941108.210418.52@arcangel.demon.co.uk> (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



                 reply	other threads:[~1994-11-08 21:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
replies disabled

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