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-Thread: 103376,23f57930ddc13e1c X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns11feed!worldnet.att.net!204.71.34.3!newsfeed.cwix.com!newsfeed.vmunix.org!news.cs.univ-paris8.fr!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Missing Index Value in Array Aggregate Date: Wed, 26 Sep 2007 18:33:48 -0500 Organization: Jacob's private Usenet server Message-ID: References: <1i50iqb.14r2zb11w8eyc2N%csampson@inetworld.net> <1190822071.488118.316450@y42g2000hsy.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1190849459 9275 69.95.181.76 (26 Sep 2007 23:30:59 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 26 Sep 2007 23:30:59 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1896 Xref: g2news2.google.com comp.lang.ada:2152 Date: 2007-09-26T18:33:48-05:00 List-Id: "Adam Beneschan" wrote in message news:1190822071.488118.316450@y42g2000hsy.googlegroups.com... ... > Note, though, that array *types* don't have bounds on their indexes. > An array subtype is an array type plus (possibly) a constraint, where > the constraint puts bounds on the indexes. Once the type of the above > aggregate is determined, the aggregate will have an (unnamed) subtype > of that type with a constraint of (2..4). Then, depending on what you > do with that aggregate, the subtype will be *converted* to some other > subtype. If you declare an object: > > type int4 is array(1..4) of integer; > A : int4 := (2 => 1010, 3 => 2020, 4 => 3030); To expand on this a bit, in Ada 95, array bounds "slide" on assignment - only the length of the array matters. So the bounds given in the aggregate are not necessarily meaningful. The assignment type int3 is array(1..3) of integer; A : int3 := (2 => 1010, 3 => 2020, 4 => 3030); is legal and does not raise Constraint_Error. Thus the number of cases where you could tell statically that the aggregate is wrong is fairly few. There are some, though; if the index values aren't continguous, the aggregate is illegal: type int3 is array(1..3) of integer; A : int3 := (1 => 1010, 3 => 2020, 4 => 3030); -- Illegal. And, as Adam points out, I'm not aware of any Ada compiler that doesn't put out a warning when it knows an exception is going to be raised. Don't turn off (or ignore) all warnings! Randy.