comp.lang.ada
 help / color / mirror / Atom feed
From: ANH_VO@udlp.com
To: comp.lang.ada@ada.eu.org
Subject: Re[2]: I'm baffled...
Date: Wed, 31 Oct 2001 10:03:18 -0600
Date: 2001-10-31T10:03:18-06:00	[thread overview]
Message-ID: <mailman.1004553394.24498.comp.lang.ada@ada.eu.org> (raw)


<<  subtype index is positive range word_list'range;

current_index jumps around but is always in index >>

Here is your problem. First, I would like to recapture the function call here
for easy discussion.

      Result : Index := 47;
   begin
      Result := ASF.Index (
         Source  => Word_List (Current_Index + 1 .. Word_List'Last),
         Pattern => Pattern,
         Going   => AS.Forward );

The problem is that the function ASF.Index returns 0 if pattern is not found.
However, the Result is declared as Positive, type Index. Therefore,
Constraint_Error is raised at the assignment.

The obvious solution is to change Index type to include 0. As far as error
message is concerned, I think GNAT gave a very confusing / incorrect message,
a-strmap.ads:166. In addition, APEX and ObjectAda pointed to the exact line
where the Constraint_Error was raised.

A. Vo



                 reply	other threads:[~2001-10-31 16:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox