# 4.13 POINTER Statement

The POINTER statement establishes pairs of variables and pointers, in which each pointer contains the address of its paired variable.

The POINTER statement takes the following form:

    POINTER (pointer,pointee) [,(pointer,pointee)] . . .

pointer
  Is a variable whose value is used as the address of the pointee.
pointee
  Is a variable, array, array declarator, record, record array, or record array declarator.

Rules and Behavior

The following are pointer rules and behavior:

- Two pointers can have the same value, so pointer aliasing is allowed.

- When used directly, a pointer is treated like an integer variable. On VAX processors, a pointer occupies one numeric storage unit, so it is a 32-bit quantity (INTEGER*4). On Alpha processors, a pointer occupies two numeric storage units, so it is a 64-bit quantity (INTEGER*8).

- A pointer cannot be a pointee.

- A pointer cannot appear in the following statements:

ASSIGN | INTRINSIC
EXTERNAL | PARAMETER

A pointer can appear in a DATA statement with integer literals only.

- Integers can be converted to pointers, so you can point to absolute memory locations.

- A pointer variable cannot be declared to have any other data type.

- A pointer cannot be a function return value.

- You can give values to pointers by using the %LOC built-in function to retrieve addresses, or by using `malloc(3f)` on Tru64 UNIX systems to allocate storage for an object. For example:

      Using %LOC:                     Using malloc:

      INTEGER I(10)                   INTEGER I(10)

      INTEGER I1 (10) /10*10/         POINTER (P,I)

      POINTER (P,I)                   P = MALLOC (40)

      P = %LOC (I1)                   I(2) = I(2) + 1

      I(2) = I(2) + 1

- The value in a pointer is used as the pointee's base address.

  The following are pointee rules and behavior:

  - A pointee is not allocated any storage. References to a pointee look to the current contents of its associated pointer to find the pointee's base address.

  - A pointee cannot be data-initialized or have a record structure that contains data-initialized fields.

  - A pointee can appear in only one POINTER statement.

  - A pointee array can have fixed, adjustable, or assumed dimensions.

  - A pointee cannot appear in the following statements:

    AUTOMATIC | NAMELIST
    COMMON | PARAMETER
    DATA | SAVE
    EQUIVALENCE | STATIC

  - A pointee cannot be a dummy argument.

  - A pointee cannot be a function return value.

  - A pointee cannot be a record field or an array element.

  Previous Page Next Page Table of Contents