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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f849b,b8d52151b7b306d2 X-Google-Attributes: gidf849b,public X-Google-Thread: 103376,a00006d3c4735d70 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-27 09:05:55 PST Message-ID: <3fedbbf0_3@mk-nntp-1.news.uk.worldonline.com> From: Ian Bell Subject: Re: Certified C compilers for safety-critical embedded systems Newsgroups: comp.arch.embedded,comp.lang.ada Followup-To: comp.arch.embedded Date: Sat, 27 Dec 2003 17:08:43 +0000 References: <3fe00b82.90228601@News.CIS.DFN.DE> <3FE026A8.3CD6A3A@yahoo.com> <$km9afA3DB7$EAYO@phaedsys.demon.co.uk> <3feda44e_3@mk-nntp-1.news.uk.worldonline.com> Organization: REMAP User-Agent: KNode/0.7.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit NNTP-Posting-Host: ppp-225-3-100.friaco.access.uk.tiscali.com X-Trace: 27 Dec 2003 17:05:53 GMT, ppp-225-3-100.friaco.access.uk.tiscali.com Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!crtntx1-snh1.gtei.net!washdc3-snh1.gtei.net!news.gtei.net!ngpeer.news.aol.com!feed2.newsreader.com!newsreader.com!newshosting.com!news-xfer2.atl.newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!kibo.news.demon.net!demon!mk-nntp-1.news.uk.worldonline.com!ppp-225-3-100.friaco.access.uk.tiscali.com Xref: archiver1.google.com comp.arch.embedded:6162 comp.lang.ada:3852 Date: 2003-12-27T17:08:43+00:00 List-Id: Simon Wright wrote: > Ian Bell writes: > >> James Rogers wrote: >> >> snip >> > >> > type my_index is range 0..9; >> > type My_Array_Type is array(my_index) of integer; >> > >> > foo : My_Array_Type; >> > >> > for num in 0..99 loop >> > foo(num) := num; >> > end loop; >> > >> > All Ada compilers will correctly identify the error in the for >> > loop. The type of "num" is not the same as the type of the index, >> > because the range of values defined for "num" are not all within >> > the range of values in my_index. This detection will happen >> > properly no matter how far the definition is separated from the >> > "for" loop. >> >> I know nothing about ada so this is a genuine query rather than a >> ctiticism. The above example is fine as long as literals are used - >> even a C compiler could be devised to make this check - but what >> happens when the array index is computed? > > You mean as in > > type my_index is range 0 .. some_variable; > > -- yes, Ada compilers will perform the check. > That was not what I had in mind and seems to me to be rather dodgy code. i was thinking more of the return value of some function being used as an index to the array. Ian