TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Classic View

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

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

Print Reply
Peter Amey <[log in to unmask]>
Tue, 8 Jul 2003 08:13:27 +0100
text/plain (46 lines)
> -----Original Message-----
> From: Apurva Shukla [mailto:[log in to unmask]]
> Sent: 08 July 2003 06:44
> To: [log in to unmask]
> Subject: The array range problem
> Hi all,
> I am a starter in Ada and need certain help ragrding arrays. 
> i have got
> a code in which there is a line which says:
> a(11..10) := b(1..0);
> here the arrays a and b are of the same type( i have tried 
> using integer )
> and the range is (1..10)
> So my questions are:
> 1. Why is ada compiler not noticing that the array range has been
> voilated by saying a(11..10)
> 2. And this progarm runs also but the values are not 
> providing any clue
> of what ada compiler does exactly.

With the caveat that I keep forgetting the bits of Ada that aren't SPARK here's one possible answer:

11..10 and 1..0 are both null slices (i.e. statically known to be empty).  Your code therefore assigns a null slice to a null slice and no out-of-bounds array accesses occur so no error occurs. 

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



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.