Version 1.4 of ai05s/ai05-0078-1.txt
!standard 13.9(7) 08-04-18 AI05-0078-1/03
!class binding interpretation 07-12-06
!status WG9 Approved 08-06-20
!status ARG Approved 7-0-1 08-02-09
!status work item 07-12-06
!status received 07-11-15
!priority Low
!difficulty Easy
!qualifier Clarification
!subject Alignment need not match for Unchecked_Conversion
!summary
The alignment of the source object of an unchecked conversion need only
be a multiple of that of the target type for unchecked conversion to have
a defined result. If the target alignment is zero, the alignment of the
source object is not relevant to whether unchecked conversion has a
defined effect.
!question
13.9(7) specifies that it is required that the source object and target
type have identical alignment for an unchecked type conversion to have
a language-defined effect.
The intent of this rule appears to be to restrict the cases
where an unchecked conversion has a language-defined effect to
situations where the source object representation is valid with respect
to the target type's alignment (allowing the representation of the
source object to be viewed as a correctly aligned representation
of a value of the target type).
This rule disallows cases which would still meet this intent.
It would be sufficient for S'Alignment to be any multiple of
Target'Alignment.
Should this clause be changed? (Yes.)
!recommendation
(See summary.)
!wording
Replace 13.9(7) with:
S'Alignment is a multiple of Target'Alignment or Target'Alignment is zero.
!discussion
Implementations are allowed to support unchecked conversions with
mismatched alignments even without this language change
(implementation-defined surely includes working as expected).
So this language change only provides a bit of additional portability.
If the Target'Alignment is zero, multiples of that alignment are not
well-defined; since alignment being zero imposes no restrictions, there
is no reason for a requirement on S'Alignment.
!corrigendum 13.9(7)
Replace the paragraph:
- S'Alignment = Target'Alignment.
by:
- S'Alignment is a multiple of Target'Alignment or Target'Alignment is zero.
!ACATS Test
This might be testable, but it is likely that this would work anyway.
!appendix
!topic 13.9(7) is unnecessarily restrictive
!reference Ada 2005 RM 13.9(7)
!from Thomas Quinot 2007-11-15
!keywords unchecked conversion, alignment
!discussion
13.9(7) specifies that it is required that the source object and target
type have identical alignment for an unchecked type conversion to have
an RM-defined effect.
As I understand this clause, the intent of the clause is to restrict
the scope of 13.9(5) (case where an unchecked conversion has a
language-defined effect) to situations where the source object
representation is valid with respect to the target type's alignment
(allowing the representation of the source object to be viewed as a
correctly aligned representation of a value of the target type).
With respect to this intent, the restriction stated in 13.9(7) is a
sufficient, but not necessary, condition. It would be sufficient for
S'Alignment to be any multiple of Target'Alignment. So, I am suggesting
that this clause be changed to:
13.9(7) S'Alignment is a multiple of Target'Alignment
****************************************************************
From: Tucker Taft
Sent: Thursday, November 15, 2007 7:25 AM
Your suggestion makes good sense to me.
****************************************************************
Questions? Ask the ACAA Technical Agent