comp.lang.ada
 help / color / mirror / Atom feed
* Question about out parameters of unconstrained array type.
@ 2012-02-25 15:19 Peter C. Chapin
  2012-02-25 15:33 ` Dmitry A. Kazakov
  2012-02-25 18:20 ` Phil Thornley
  0 siblings, 2 replies; 15+ messages in thread
From: Peter C. Chapin @ 2012-02-25 15:19 UTC (permalink / raw)


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 either have to 1) give the parameter 
mode in out or 2) initialize S inside the procedure before doing 
anything with it (for example with an aggregate). SPARK appears to 
behave as if the entire string is uninitialized upon entry into the 
procedure... even the attributes. I'm having trouble finding information 
about this in my SPARK references also.

Peter



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2012-02-27 15:32 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-25 15:19 Question about out parameters of unconstrained array type Peter C. Chapin
2012-02-25 15:33 ` Dmitry A. Kazakov
2012-02-25 18:20 ` Phil Thornley
2012-02-25 20:01   ` Simon Wright
2012-02-25 22:44     ` Phil Thornley
2012-02-27 13:48       ` Mark Lorenzen
2012-02-27 15:32         ` Phil Thornley
2012-02-25 23:37   ` Alexander Senier
2012-02-26  1:16   ` Peter C. Chapin
2012-02-26  9:14     ` Phil Thornley
2012-02-26 12:25       ` Alexander Senier
2012-02-26 13:20         ` Phil Thornley
2012-02-26 14:25         ` Niklas Holsti
2012-02-26 17:32         ` Jeffrey Carter
2012-02-26 15:29       ` Peter C. Chapin

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