TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

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

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

Print Reply
Subject:
From:
Peter Amey <[log in to unmask]>
Reply To:
Peter Amey <[log in to unmask]>
Date:
Tue, 8 Jul 2003 08:13:27 +0100
Content-Type:
text/plain
Parts/Attachments:
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.

regards

Peter


**********************************************************************
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.
www.mimesweeper.com
**********************************************************************

ATOM RSS1 RSS2