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-Thread: 103376,bc2c82b1e5c6fe83 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.226.10 with SMTP id ro10mr6868329pbc.6.1330213075297; Sat, 25 Feb 2012 15:37:55 -0800 (PST) Path: h9ni9241pbe.0!nntp.google.com!news2.google.com!goblin3!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!85.214.198.2.MISMATCH!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Alexander Senier Newsgroups: comp.lang.ada Subject: Re: Question about out parameters of unconstrained array type. Date: Sun, 26 Feb 2012 00:37:53 +0100 Organization: A noiseless patient Spider Message-ID: <20120226003753.2f2b3224@t60> References: Mime-Version: 1.0 Injection-Info: mx04.eternal-september.org; posting-host="e6Gu2UbyOy2nuiHyFRTtfw"; logging-data="2818"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+i/kxJ70rfn6vGn3zUUNTx" X-Newsreader: Claws Mail 3.7.9 (GTK+ 2.24.6; x86_64-pc-linux-gnu) Cancel-Lock: sha1:RA/CsDLYNreSTgqO2Z3Pp/VTu6Y= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Date: 2012-02-26T00:37:53+01:00 List-Id: On Sat, 25 Feb 2012 18:20:42 -0000 Phil Thornley wrote: > there is no syntax or semantic error reported. (You will get the usual > flow error if you assign individual values of the string in the loop, > but that's another problem all together.) > > In fact the LRM states that this usage is permitted. See Section 4.1: > "... the name of an unconstrained array object (formal parameter) shall > only appear in the following contexts: > 1 as the prefix of an attribute reference; > 2 ..." As you say, using attributes of out parameters of an unconstrained array type is no problem when used inside a loop iteration scheme in SPARK. However, it seems to be when using the attribute elsewhere: 1 package P is 2 procedure Init (A : out String); 3 --# derives A from ; 4 end P; 1 package body P is 2 procedure Init (A : out String) is 3 begin 4 for I in Positive range A'First .. A'Last 5 loop 6 if A'Length > 42 7 then 8 A (I) := 'x'; 9 end if; 10 end loop; 11 end Init; 12 end P; The example yields the two expected flow errors you mention (line 8 and 11). However, the use of A'Length in line 6 also lead to an (unexpected) flow error (same for 'First and 'Last): p.adb:6:13: Flow Error 20 - Expression contains reference(s) to variable A which has an undefined value. Regards Alex