Version 1.1 of acs/ac-00179.txt
!standard 13.11.1(3/2) 09-10-22 AC95-00179/01
!class confirmation 09-10-22
!status received no action 09-10-22
!status received 09-10-12
!subject Behavior of Ada.Streams.Read when at the end of the stream
!summary
!appendix
From: Thomas Quinot
Date: Monday, October 12, 2009 1:13 PM
!topic Stream read transferring no elements
!reference Ada 2005 RM13.13.1(8/2)
!from Thomas Quinot 10-10-12
!keywords stream, bound, exception
13.13.1(8/2) specifies that a call to Ada.Streams.Read sets the out parameter
Last to Item'First - 1 when no elements are transferred. However no indication
is given for the case where Item'First = Stream_Element_Offset'First, in which
case Item'First is not a value of the subtype.
Possible approaches include:
1. special case the situation where Item'First = SEO'First,
and in that case set Last to SEO'Last (instead of SEO'First - 1)
when no element is transferred (but then there is a theoretical
issue with the case where Item'Range = Stream_Element_Offset'Range
-- though in practice having such a large array would seem
impractical).
2. in the case where Item'First = SEO'First and no element is transferred,
raise CONSTRAINT_ERROR, and in all other cases behave as currently
described.
3. in the case where Item'First = SEO'First, raise CONSTRAINT_ERROR
(before even attempting to transfer any element), and in all other
casees behave as currently described.
Other ideas?
****************************************************************
From: Randy Brukardt
Date: Monday, October 12, 2009 1:45 PM
> 13.13.1(8/2) specifies that a call to Ada.Streams.Read sets the out
> parameter Last to Item'First - 1 when no elements are transferred.
> However no indication is given for the case where Item'First =
> Stream_Element_Offset'First, in which case Item'First is not a value
> of the subtype.
There doesn't need to be any "indication" here; the wording covers all possible
cases as written. The AARM Note 13.13.1(9.b/3) makes it quite clear that the
language is correct as written (which corresponds to your "approach #2"). Note
that this AARM note is from the original Ada 95 standard (although it originally
appeared in 13.7.1; I moved it because the discussion only referred to routines
that use a Stream_Element_Array). So it is quite clear that the original design
intent was that Constraint_Error could be raised if nothing is transferred (for
both Stream_Element_Array and Storage_Element_Array).
I'm pretty sure that we've discussed (and confirmed) this issue in the past; I
remember raising it (or that someone else raised it) many years ago. But I've
been unable to find that discussion; it must be buried in some unrelated AI.
> Possible approaches include:
>
...
> 2. in the case where Item'First = SEO'First and no element is
> transferred,
> raise CONSTRAINT_ERROR, and in all other cases behave as currently
> described.
...
****************************************************************
From: Adam Beneschan
Date: Monday, October 12, 2009 1:55 PM
Looks like AI95-227: is that what you were looking for?
****************************************************************
From: Randy Brukardt
Date: Monday, October 12, 2009 2:15 PM
Yes! Thanks, Adam.
So, to summarize: this exact issue was discussed and confirmed in a previous AI
way back in 2000. There is nothing more to say on the topic.
****************************************************************
From: Thomas Quinot
Date: Tuesday, October 13, 2009 4:56 AM
Randy, Adam: thanks for the pointer to AI95-227. Indeed, this exactly answers my
question.
****************************************************************
Questions? Ask the ACAA Technical Agent