Constant and Variable Reference Modification

Restriction: This topic applies to UNIX environments only.
  1. Create the intermediate code file: Windows:
    cobol demo5.cbl /anim /nognt;
    UNIX:
    cobol -a demo5.cbl
    In this program the record p1 is accessed via a reference modification, both statically and dynamically.
  2. Run Scan64 on this program by entering the command: Windows:
    cblscan64 -m demo5
    UNIX:
    cobscan64 -m demo5
    This produces the following report:
    Processing file 'demo5.int' 
    **Unsafe modification of pointer at (file: demo5.cbl, line: 12) 
      Modifier : P1 (file: demo5.cbl, def: 6)
      Pointer : PTR2-1 (file: demo5.cbl, def: 8) 
    
    **Unsafe modification of pointer at (file: demo5.cbl, line: 13) 
      Modifier : P1 (file: demo5.cbl, def: 6) 
      Pointer : PTR2-1 (file: demo5.cbl, def: 8)
    
    **Unsafe modification of pointer at (file: demo5.cbl, line: 13)
      Modifier : P1 (file: demo5.cbl, def: 6) 
      Pointer : PTR2-2 (file: demo5.cbl, def: 9) 
    
    **Unsafe modification of pointer at (file: demo5.cbl, line: 14) 
      Modifier : P1 (file: demo5.cbl, def: 6)
      Pointer : PTR2-1 (file: demo5.cbl, def: 8) 
    
    **Unsafe modification of pointer at (file: demo5.cbl, line: 14)
      Modifier : P1 (file: demo5.cbl, def: 6)
      Pointer : PTR2-2 (file: demo5.cbl, def: 9)
    
    Finished file 'demo5.int' - pointer problems could exist 

    The first static reference modification at line 11 is correctly not reported; however the second static reference modification at line 12 will overwrite the first byte of ptr2-1, so is reported as a violation.

    At line 13 and line 14, at syntax-check the Compiler has no idea what the contents of the variable refm might be, so any pointer within the record p1 could be changed; Scan64 therefore reports possible violations of the two pointers ptr2-1 and ptr2-2.