ILE COBOL Programmer's Guide


Redefining Pointers

A pointer data item or procedure-pointer data item may be the subject or object of a REDEFINES clause.

When a pointer is the subject of a REDEFINES clause, the object data item must be on a 16-byte boundary. For example:

 WORKING-STORAGE SECTION.
  01  AB.
      05 ALPHA-NUM PIC X(16).
      05 APTR REDEFINES ALPHA-NUM USAGE POINTER.
      05 BPTR  USAGE POINTER.
      05 CPTR REDEFINES BPTR USAGE POINTER.

In the above example, both APTR and CPTR are pointer data items that redefine 16-byte aligned items. In the following example, the redefined item would result in a severe compiler error:

 WORKING-STORAGE SECTION.
  01  EF.
      05 ALPHA-NUM PIC X(5).
      05 HI.
         10 ALPHA-NUM-TWO PIC X(11).
         10 APTR  USAGE POINTER.
      05 BPTR REDEFINES HI USAGE POINTER.

In the above example, APTR is aligned on a 16-byte boundary. That is, the ILE COBOL compiler did not need to add FILLER items to align APTR. The group item HI is not on a 16-byte boundary, and so neither is pointer data item BPTR. Because the ILE COBOL compiler cannot add FILLER items to place BPTR on a 16-byte boundary, a severe error will result.

In the following example, similar to the above, the ILE COBOL compiler is able to place the pointer data item on a 16-byte boundary:

 WORKING-STORAGE SECTION.
  01  EF.
      05 ALPHA-NUM PIC X(5).
      05 HI.
         10 ALPHA-NUM-TWO PIC X(11).
         10 APTR  USAGE POINTER.
         10 ALPHA-NUM-THREE PIC X(5).
      05 KL REDEFINES HI.
         10 BPTR USAGE POINTER.

In the above example, group item KL is not on a 16-byte boundary; however, the compiler adds an 11-byte FILLER before pointer data item BPTR to ensure that it falls on a 16-byte boundary.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]