From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,caf3a6bfcfd3e965,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-11-11 16:15:12 PST Newsgroups: comp.lang.ada Path: nntp.gmd.de!xlink.net!zib-berlin.de!prise.nz.dlr.de!news.dfn.de!swiss.ans.net!howland.reston.ans.net!pipex!demon!betanews.demon.co.uk!arcangel.demon.co.uk!pjb From: pjb@arcangel.demon.co.uk (Peter Burwood) Subject: Do compilers generate enough warnings ? Message-ID: <19941108.210418.52@arcangel.demon.co.uk> Sender: news@demon.co.uk (Usenet Administration) Nntp-Posting-Host: arcangel.demon.co.uk Reply-To: pjb@arcangel.demon.co.uk Organization: At Home X-Newsreader: Risc PC TTFN Version 0.33 Date: Tue, 8 Nov 1994 21:04:18 GMT Date: 1994-11-08T21:04:18+00:00 List-Id: 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