Bug in CPP only.
The following works fine if compiled as executable (-x), but not if compiled as module (-m):
IDENTIFICATION DIVISION. PROGRAM-ID. prog. DATA DIVISION. WORKING-STORAGE SECTION. 01 MYFLD BASED. 03 MYFLDX PIC X. 03 MYFLD9 PIC 9. PROCEDURE DIVISION. IF ADDRESS OF MYFLD NOT = NULL DISPLAY "BASED ITEM WITH ADDRESS ON START" END-DISPLAY END-IF. FREE MYFLD. ALLOCATE MYFLD. IF ADDRESS OF MYFLD = NULL DISPLAY "BASED ITEM WITHOUT ADDRESS AFTER ALLOCATE" END-DISPLAY END-IF. INITIALIZE MYFLD. IF MYFLD NOT = " 0" DISPLAY "BASED ITEM INITIALIZED WRONG: " WITH NO ADVANCING END-DISPLAY DISPLAY MYFLD END-DISPLAY END-IF. FREE ADDRESS OF MYFLD. IF ADDRESS OF MYFLD NOT = NULL DISPLAY "BASED ITEM WITH ADDRESS AFTER FREE" END-DISPLAY END-IF.
struct _s1_MYFLD (prog.cpp.h) is generated twice, cob_free_alloc is not called correctly on CANCEL.
Fixed with [r192], testcase was added (will be merged into 2.x later on).
Log in to post a comment.