The predefined generic library subprograms UNCHECKED_DEALLOCATION and UNCHECKED_CONVERSION are used for unchecked storage deallocation and for unchecked type conversions.
generic type OBJECT is limited private; type NAME is access OBJECT; procedure UNCHECKED_DEALLOCATION(X: in out NAME); generic type SOURCE is limited private; type TARGET is limited private; function UNCHECKED_CONVERSION(S : SOURCE) return TARGET;
References: generic subprogram, library unit, type.
Rationale references: 15.8 Unchecked Conversions
Sub-topics:
Unchecked storage deallocation of an object designated by a value of an access type is achieved by a call of a procedure that is obtained by instantiation of the generic procedure UNCHECKED_DEALLOCATION. For example:
procedure FREE is new UNCHECKED_DEALLOCATION(object_type_name, access_type_name);
Such a FREE procedure has the following effect:
Notes:
It is a consequence of the visibility rules that the generic procedure UNCHECKED_DEALLOCATION is not visible in a compilation unit unless this generic procedure is mentioned by a with clause that applies to the compilation unit.
If X designates a task object, the call FREE(X); has no effect on the task designated by the value of this task object. The same holds for any subcomponent of the object designated by X, if this subcomponent is a task object.
References: access type, apply, compilation unit, designate, and 9.1, erroneous, generic instantiation, generic procedure, generic unit, library unit, null access value, object, procedure, procedure call, subcomponent, task, task object, visibility, with clause.
Style Guide references: 5.4.3 Dynamic Data, 5.9.2 Unchecked Deallocation, 7.6.6 Unchecked Deallocation
An unchecked type conversion can be achieved by a call of a function that is obtained by instantiation of the generic function UNCHECKED_CONVERSION.
The effect of an unchecked conversion is to return the (uninterpreted) parameter value as a value of the target type, that is, the bit pattern defining the source value is returned unchanged as the bit pattern defining a value of the target type. An implementation may place restrictions on unchecked conversions, for example, restrictions dependeing on the respective sizes of objects of the source and target type. Such restrictions must be documented in Appendix F.
Whenever unchecked conversions are used, it is the programmer's responsibility to ensure that these conversions maintain the properties that are guaranteed by the language for objects of the target type. Programs that violate these properties by means of unchecked conversions are erroneous.
Note:
It is a consequence of the visibility rules that the generic function UNCHECKED_CONVERSION is not visible in a compilation unit unless this generic function is mentioned by a with clause that applies to the compilation unit.
References: apply, compilation unit, erroneous, generic function, instantiation, parameter of a subprogram, type, with clause.
Style Guide references: 5.9.1 Unchecked Conversion, 7.6.7 Unchecked Conversion
Address any questions or comments to adainfo@sw-eng.falls-church.va.us.