TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Classic View

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

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

Print Reply
Stephen Leake <[log in to unmask]>
Tue, 8 Jul 2003 09:58:25 -0400
text/plain (24 lines)
Jean-Pierre Rosen <[log in to unmask]> writes:

> >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.
> No. A null slice never raises Constraint_Error (4.1.2(7)).

You missed that he changed things for this statement; "a (10 .. 11)" is
_not_ a null slice.

The original example was "a (11 .. 10)", which _is_ a null slice.

The point is that for null slices, the indices are not checked. So
even though "11" is outside the bounds of indices of "a", "a (11 ..
10)" does not raise Constraint_Error. But for "a (10 .. 11)",
Constraint_Error is raised, since it is not a null slice.

-- Stephe