TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Peter Amey <[log in to unmask]>
Reply To:
Peter Amey <[log in to unmask]>
Tue, 8 Jul 2003 13:26:38 +0100
text/plain (50 lines)

-----Original Message-----
From: Apurva Shukla [mailto:[log in to unmask]]
Sent: 08 July 2003 12:29
To: [log in to unmask]
Subject: Re: The array range problem

I would hope that a(10..11) := b(0..1); would raise a rich crop of constraint errors.


but it Does give an error .
I tried and it compiles well and then gives a CONSTRAINT_ERROR on  running. and even 
a(10..11) := b(10..11)
gives and error.
a(11..10) := b(10..9)
runs perfectly

Still strange for me. and hope to hear from you all
thanks in advance


This behaviour is exactly what I would expect.  In the 11..10 case both ranges are statically empty, nothing is being assigned so there are no out-of-range values.  This is the answer I gave before, J-P Rosen added the LRM reference.
In the 10..11 case, the ranges are not null so the bounds are evaluated.  11 is outside the array index range of 1..10 so a constraint error occurs (the 0 in the second expression is also out of range).
The only surprise to me is that the error occurs at run-time; I would expect a compiler to spot the static out-of-range value during compilation.

This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.  The IT Department at Praxis Critical Systems can be contacted at [log in to unmask]
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.