From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7a1691a2185bb3e7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-01-21 12:14:44 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!lnsnews.lns.cornell.edu!paradoxa.ogoense.net!sn-xit-04!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Matthew Heaney" Newsgroups: comp.lang.ada Subject: Re: Bounds of Slice's return value Date: Mon, 21 Jan 2002 15:19:27 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: <87bsfrcksf.fsf@chiark.greenend.org.uk> X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 X-Complaints-To: newsabuse@supernews.com Xref: archiver1.google.com comp.lang.ada:19149 Date: 2002-01-21T15:19:27-05:00 List-Id: "Matthew Woodcraft" wrote in message news:87bsfrcksf.fsf@chiark.greenend.org.uk... > In particular, if I run the following program, should I always get '1', > or is an implementation allowed to choose a different value? > > procedure Slice_Return_Value is > U : Unbounded_String := To_Unbounded_String ("hello"); > S : String := Slice (U, 2, 3); > begin > Put_Line (Integer'Image (S'first)); > end Slice_Return_Value; You can fix this to specify the index constraint you desire, using a subtype constraint: declare F : constant Positive := 2; L : constant Positive := 3; S : constant String (1 .. L - F + 1) := Slice (U, F, L); begin or declare F : constant Positive := 2; L : constant Positive := 3; S : constant String (F .. L) := Slice (U, F, L); begin Of course, this declares a constrained string object (no dope vector is generated), so this is not strictly comparable to your original example. You could fix that by using an explicit subtype: declare F : constant Positive := 2; L : constant Positive := 3; subtype T is String (1 .. L - F + 1); S : constant String := T(Slice (U, F, L)); begin or declare F : constant Positive := 2; L : constant Positive := 3; subtype T is String (F .. L); S : constant String := T(Slice (U, F, L)); begin