Data pointer assignment
Pointer assignment statement causes a pointer to become associated with a target or causes the pointer's association status to become disassociated or undefined.
- data_pointer_object
- must have the POINTER attribute.
- target
- is a variable or expression. If it is a variable, it must have
the TARGET attribute (or be a subobject
of such an object) or the POINTER attribute.
If it is an expression, it must yield a value that has the POINTER attribute.
If target is not unlimited polymorphic, data_pointer_object must be type compatible with it and the corresponding kind type parameters must be equal. If target is unlimited polymorphic, data_pointer_object must be unlimited polymorphic, of sequence derived type, or of a type with the BIND attribute.
- bounds_spec
-
- lower_bound
- is a scalar integer expression.
- bounds_remapping
-
- lower_bound
- is a scalar integer expression.
- upper_bound
- is a scalar integer expression.
A target must not be an array section with a vector subscript, or a whole assumed-size array.
The size, bounds, and shape of the target of a disassociated array pointer are undefined. No part of such an array can be defined or referenced, although the array can be the argument of an intrinsic inquiry function that is inquiring about association status, argument presence, or a property of the type or type parameters.
A pointer of type byte can only be associated with a target of type byte, INTEGER(1), or LOGICAL(1).
If a data_pointer_object is an array with the CONTIGUOUS attribute, the target must be contiguous.
If target is a disassociated pointer, all nondeferred type parameters of the declared type of data_pointer_object that correspond to nondeferred type parameters of target shall have the same values as the corresponding type parameters of target. Otherwise, all nondeferred type parameters of the declared type of data_pointer_object must have the same values as the corresponding type parameters of target.
If data_pointer_object has nondeferred type parameters that correspond to deferred type parameters of target, target must not be a pointer with undefined association status.
If the data_pointer_object is not polymorphic and the target is polymorphic with dynamic type that differs from its declared type, the assignment target is the ancestor component of target that has the type of data_pointer_object. Otherwise, the assignment target is target.
If data_pointer_object is polymorphic, it assumes the dynamic type of target. If data_pointer_object is of sequence derived type or a type with the BIND attribute, the dynamic type of target must be that type.
If you specify bounds_spec_list, the number of bounds in the list must be equal to the rank of data_pointer_object.
If you specify either a bounds_spec_list or a bounds_remapping_list, you must not use a SUBSCRIPTORDER directive on the pointer
- The target must be simply contiguous or of rank one.
- The target must not be a diassociated or undefined pointer, and the size of the target must not be less than the size of the data_pointer_object.
- The number of bounds_remappings in the list must be equal to the rank of data_pointer_object.
- The lower bound of each dimension of the data_pointer_object becomes equal to the lower_bound you specify in the corresponding bounds_remapping.
- The upper bound of each dimension of the data_pointer_object becomes equal to the upper_bound you specify in the corresponding bounds_remapping.
- The extent of each dimension of the data_pointer_object is equal to the upper bound of that dimension, minus the lower bound of that dimension, plus 1.
- The elements of the target of data-pointer-object, in array element order, are the first SIZE (data-pointer-object) elements of the target, after any SUBSCRIPTORDER directives affect the target.
- The number of bounds_spec shall equal the rank of data_pointer_object.
- If you specify a bounds_spec_list, then the lower_bound of each dimension of the data_pointer_object becomes equal to the lower_bound in the corresponding bounds_spec.
- The extent of each dimension of the data_pointer_object is equal to the extent of the corresponding dimension of the target.
- The upper bound of each dimension of the data_pointer_object is equal to the lower bound of that dimension, plus the extent of that dimension, minus 1.
If neither bounds_remapping_list nor bounds_spec_list are specified:
During pointer assignment of an array pointer, the lower bound of each dimension is the result of the LBOUND intrinsic function applied to the corresponding dimension of the target. For an array section or array expression that is not a whole array or a structure component, the lower bound is 1. The upper bound of each dimension is the result of the UBOUND intrinsic function applied to the corresponding dimension of the target.
Any previous association between a data_pointer_object and a target is broken. If target is not a pointer, data_pointer_object becomes associated with target. If target is itself an associated pointer, data_pointer_object is associated with the target of target. If target is a pointer with an association status of disassociated or undefined, data_pointer_object acquires the same status. If target of a pointer assignment is an allocatable object, it must be allocated.
Pointer assignment for a pointer structure component can also occur via execution of a derived-type intrinsic assignment statement or a defined assignment statement.
Related information
- See ALLOCATE for an alternative form of associating a pointer with a target.
- Contiguity