Version 1.1 of acs/ac-00068.txt

Unformatted version of acs/ac-00068.txt version 1.1
Other versions for file acs/ac-00068.txt

!standard 13.9(07)          03-08-04 AC95-00068/01
!class amendment 03-08-04
!status received no action 03-08-04
!status received 03-01-21
!subject Too strict Unchecked_Conversion alignment requirement
!summary
!appendix

!topic Too strict Uncheked_Conversion alignment requirement
!reference RM95-13.9(7)
!from Victor Porton 03-01-22
!keywords align, alignment, Uncheked_Conversion, unchecked type conversions
!discussion

13.9(3) "function Ada.Unchecked_Conversion(S : Source) return Target;"

The request of Standard 13.9(7) "S'Alignment = Target'Alignment" is
unnecessarily strict and not enough flexible.

In the current Standard seems to be no portable way to place into an
Ada.Storage_Elements.Storage_Array an object of arbitrary alignment > 1
(because alignment of the array may and of its slices may be different,
specifying alignment of the array by for..use clause is not always possible as
it may be allocated by "new"). By placing an object into array I mean applying
Unchecked_Conversion to the array (or an its slice) which would return an
object of the given type.

One needs this for allocating a Storage_Array (by "new") and then placing
arbitrary objects in its slices (e.g. creating an user defined-allocator which
in turn uses the default allocator). It is a real task which has arisen before
me when I tried to make my program more efficient.

So I propose to replace the requirement

"S'Alignment = Target'Alignment"

to the less strong requirement

"Target'Alignment = 0 or else S'Address mod Target'Alignment = 0".

This requirement seems being always enough in any reasonable implementation,
most probably including all existing Ada implementations, so seems no need to
change anything in compilers.

****************************************************************


Questions? Ask the ACAA Technical Agent