Runtime errors because of uninitialized variables being converted to a display type

You will receive runtime error messages if the sender in a statement is moved to the receiver but the sender does not contain valid data for the type of the receiver, possibly because the variable being moved was not initialized.

When you run a program that contains an uninitialized variable, you will receive the error messages in the following example:

$cat tcConvert2DisplayType.cbl
     000010 IDENTIFICATION DIVISION.
     000020 PROGRAM-ID. "TEST-CASE".
     000030 ENVIRONMENT DIVISION.
     000040 CONFIGURATION SECTION.
     000050 DATA DIVISION.
     000060 WORKING-STORAGE SECTION.
     000070 01 EMP-INFO.
     000080    05  EMP-ID PIC S9(5) sign is trailing separate. 
     000090 01 EMP-ID2 PIC S9(4).
     000100 PROCEDURE DIVISION.
     000120     MOVE EMP-ID OF EMP-INFO TO EMP-ID2.              
     000130     STOP RUN.
$ cob2 -o tcConvert2DisplayType tcConvert2DisplayType.cbl
IBM COBOL for Linux 1.2.0 compile started
End of compilation 1,  program TEST-CASE,  no statements flagged.
> tcConvert2DisplayType
  Traceback:
/opt/ibm/cobol/rte/usr/lib/libcob2_64r.so(+0xa6302)[0x7f46046d9302]
/opt/ibm/cobol/rte/usr/lib/libcob2_64r.so(writeERRmsg+0x72e)[0x7f46046b0d2e]
/opt/ibm/cobol/rte/usr/lib/libcob2_64r.so(+0x7e762)[0x7f46046b1762]
/opt/ibm/cobol/rte/usr/lib/libcob2_64r.so(_iwzcBCD_CONV_ZndTS_To_ZndTO+0x356)[0x7f460466f446]
tcConvert2DisplayType(TEST-CASE+0xce)[0x560b45e13eca]
    --- End of call chain ---
IWZ040S  An invalid separate sign was detected.
IWZ901S  Program exits due to severe or critical error.

Aborted (core dumped)
Initialize EMP-ID of EMP-INFO to 0:
$ cat sol-tcConvert2DisplayType.cbl
     000010 IDENTIFICATION DIVISION.
     000020 PROGRAM-ID. "TEST-CASE".
     000030 ENVIRONMENT DIVISION.
     000040 CONFIGURATION SECTION.
     000050 DATA DIVISION.
     000060 WORKING-STORAGE SECTION.
     000070 01 EMP-INFO.
     000080    05  EMP-ID PIC S9(5) SIGN IS TRAILING SEPARATE
              VALUE ZERO. 
     000090 01 EMP-ID2 PIC S9(4).
     000100 PROCEDURE DIVISION.
     000120     MOVE EMP-ID OF EMP-INFO TO EMP-ID2.              
     000130     STOP RUN.

In addition to initializing EMP-ID to 0, you can compile by using -qwsclear, which clears a program’s WORKING-STORAGE to binary zeros when the program is initialized. The storage is cleared before any VALUE clauses are applied. However, this approach is not preferred because of performance considerations.