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=0.7 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,REPLYTO_WITHOUT_TO_CC autolearn=no 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.135.231 with SMTP id pv7mr6266469pbb.8.1330194055638; Sat, 25 Feb 2012 10:20:55 -0800 (PST) Path: h9ni8415pbe.0!nntp.google.com!news1.google.com!goblin1!goblin.stu.neva.ru!news.osn.de!diablo2.news.osn.de!87.79.20.101.MISMATCH!newsreader4.netcologne.de!news.netcologne.de!zen.net.uk!hamilton.zen.co.uk!prichard.zen.co.uk.POSTED!not-for-mail From: Phil Thornley Newsgroups: comp.lang.ada Subject: Re: Question about out parameters of unconstrained array type. Date: Sat, 25 Feb 2012 18:20:42 -0000 Message-ID: References: Reply-To: phil.jpthornley@gmail.com MIME-Version: 1.0 User-Agent: MicroPlanet-Gravity/3.0.4 Organization: Zen Internet NNTP-Posting-Host: 7a972244.news.zen.co.uk X-Trace: DXC=Kdf7ZoTc:Di@1V>X_9IZai0g@SS;SF6ngR9OH0:RnENdbU_La]LM3:egPN:7kYdTYkXAEm3]H9bmn X-Complaints-To: abuse@zen.co.uk Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-02-25T18:20:42+00:00 List-Id: In article , PChapin@vtc.vsc.edu says... > > Consider a simple procedure > > procedure P(S : out String) is > begin > ... > end P; > > Despite the fact that S behaves as if it is uninitialized my Ada > compiler (GNAT GPL 2011) allows me to read certain attributes. For > example if the body is > > for I in 1 .. S'Length loop ... > > (never mind that I'm making a bad assumption about S'First being 1) I > don't see any warning about reading an uninitialized value when I do > S'Length. This is fine but I'm having trouble locating in the LRM where > this behavior is explicitly said to be well defined. Is it well defined? > Where does it say so? > > The reason I'm asking is because SPARK does *not* like the usage of > S'Length in my example above. I think that you may be misinterpreting the SPARK error message: 15 for I in 1 .. S'Length loop ^ *** Syntax Error : reserved word "IN" cannot be followed by INTEGER_NUMBER here. The error here is that the loop index has an anonymous subtype. If you change this to: for I in Integer range 1 .. S'Length loop 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 ..." Cheers, Phil