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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3f267467312181f1 X-Google-Attributes: gid103376,public From: matthew_heaney@acm.org (Matthew Heaney) Subject: Re: problem in changing Discriminants from access type Date: 1998/05/11 Message-ID: #1/1 X-Deja-AN: 352434417 Content-Transfer-Encoding: 8bit References: <35577418.0@news1.ibm.net> <35577DC2.1A8D482B@cacd.rockwell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Organization: Network Intensive Newsgroups: comp.lang.ada Date: 1998-05-11T00:00:00+00:00 List-Id: In article <35577DC2.1A8D482B@cacd.rockwell.com>, aalowe@cacd.rockwell.com wrote: (start of quote) Did the compiler tell which line would cause the constraint error? On the first declaration of the discriminant you have start at 1 and end at 0 resulting in (1..0) which is definiatly a constraint error. (end of quote) No. The index range 1 .. 0 designates a null range, and so the array object is null. The rule was carefully designed to *prevent* Constraint_Errors. The rule is that, for a null range, you're allowed to violate the constraints of the subtype (though not of the base type). For example, 1 .. 0 -1001 .. -1002 1002 .. 1001 are all legal index ranges. Note that the latter two ranges aren't even in the Int_Limits subtype. This is perfectly legal, and will NOT raise CE. That's why you can say S : String (1 .. 0); even though 0 is outside the index subtype of type String (Positive). It's the reason why S : String (-1 .. -527); is legal too, and won't raise CE. This rule is designed so you won't have to litter your code with special tests for a null slice.