Previous Topic Next topic Print topic


Modification of Pointers by Implicit Redefinition

demo1.cbl is a short COBOL program that contains such pointer operations.

  1. Create the intermediate code file:
    cob demo1.cbl
  2. Run Scan64 on this program by entering the command:
    cobscan64 demo1
    This produces the following report:
    Processing file 'demo1.int' 
    **Unsafe modification of pointer at (file: demo1.cbl, line: 9) 
      Pointer : PP (file: demo1.cbl, def: 6)
    
    Finished file 'demo1.int' - pointer problems could exist

Look at the source for demo1.cbl. Line 9 of the program contains the following:

move low-values to ppg

This modification of the group item containing the pointer pp is unsafe, as the memory occupied by the pointer pp is treated as an alphanumeric data item. In this case, since low-values is being moved, no changes are necessary. However, it would be better practice to change the code at line 9 to:

set pp to null 

It can be difficult in COBOL to identify the point at which a pointer is modified. Use the Scan64 -m option to help you identify code that modifies pointers.

For example:

cobscan64 -m demo1

produces:

Processing file 'demo1.int' 
**Unsafe modification of pointer at (file: demo1.cbl, line: 9)
  Modifier : PPG (file: demo1.cbl, def: 5)
  Pointer : PP (file: demo1.cbl, def: 6)
  Finished file 'demo1.int' - pointer problems could exist
Previous Topic Next topic Print topic