Prev | Up | Next | Back | Forward
TOC -- / --.-- / --.--.-- | Index | Search | Syntax | Help


13.9 Unchecked Type Conversions -- TOC

(1)
An unchecked type conversion can be achieved by a call to an instance of the generic function Unchecked_Conversion.
Static Semantics
(2)
The following language-defined generic library function exists:
(3)
       generic
          type Source(<>) is limited private;
          type Target(<>) is limited private;
       function Ada.Unchecked_Conversion(S : Source) return Target;
       pragma Convention(Intrinsic, Ada.Unchecked_Conversion);
       pragma Pure(Ada.Unchecked_Conversion);
Dynamic Semantics
(4)
The size of the formal parameter S in an instance of Unchecked_Conversion is that of its subtype. This is the actual subtype passed to Source, except when the actual is an unconstrained composite subtype, in which case the subtype is constrained by the bounds or discriminants of the value of the actual expression passed to S.
(5)
If all of the following are true, the effect of an unchecked conversion is to return the value of an object of the target subtype whose representation is the same as that of the source object S:
(6)
(7)
(8)
(9)
(10)
(11)
Otherwise, the effect is implementation defined; in particular, the result can be abnormal (see 13.9.1).
Implementation Permissions
(12)
An implementation may return the result of an unchecked conversion by reference, if the Source type is not a by-copy type. In this case, the result of the unchecked conversion represents simply a different (read-only) view of the operand of the conversion.
(13)
An implementation may place restrictions on Unchecked_Conversion.
Implementation Advice
(14)
The Size of an array object should not include its bounds; hence, the bounds should not be part of the converted data.
(15)
The implementation should not generate unnecessary run-time checks to ensure that the representation of S is a representation of the target type. It should take advantage of the permission to return by reference when possible. Restrictions on unchecked conversions should be avoided unless required by the target environment.
(16)
The recommended level of support for unchecked conversions is:
(17)

Subclauses

  1. Data Validity
  2. The Valid Attribute


Prev | Up | Next | Back | Forward
TOC -- / --.-- / --.--.-- | Index | Search | Syntax | Help

Ada WWW Home -- Email comments, additions, corrections, gripes, kudos, etc. to:

Magnus Kempe -- Magnus.Kempe@di.epfl.ch
Copyright statement
Page last generated: 95-03-12