bug-gnucobol
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[open-cobol-list] Bug Report and Fix


From: Robert Sherry
Subject: [open-cobol-list] Bug Report and Fix
Date: Wed Nov 16 12:00:03 2005

Gentlemen (Including Roger While),

 

First, I claim that variables defined in the COBOL LINKAGE SECTION need to hold their values between subroutine calls. This is not currently happening in the latest version of the Open Source COBOL COMPILER. Please consider the following two COBOL Programs. It consists of a main program and a subroutine:

 

Main Program:

 

       IDENTIFICATION DIVISION.

       PROGRAM-ID. top1.

 

       ENVIRONMENT DIVISION.

       CONFIGURATION SECTION.

       DATA DIVISION.

       WORKING-STORAGE SECTION.

       01 FUN-NAME PIC X(8) VALUE 'FOO'.

       PROCEDURE DIVISION.

           CALL 'bot' USING '1' FUN-NAME.

           CALL 'bot' USING '0'.

           GOBACK.

 

Subroutine:

 

       IDENTIFICATION DIVISION.

       PROGRAM-ID. bot.

 

       ENVIRONMENT DIVISION.

       CONFIGURATION SECTION.

       DATA DIVISION.

       WORKING-STORAGE SECTION.

       LINKAGE SECTION.

       01 LN-MODE PIC X(1).

       01 LN-VAL PIC X(8).

       01 LN-NAME PIC X(8).

       PROCEDURE DIVISION USING LN-MODE LN-VAL.

           IF LN-MODE = '1'

             SET ADDRESS OF LN-NAME TO ADDRESS OF LN-VAL

           ELSE

             DISPLAY 'NAME=' LN-NAME

           END-IF.

           GOBACK.

 

When compiled with the latest version of the Open Source COBOL Compiler the above programs dies with a core dump. The function output_internal_function has the following line of code:

                 output_line ("unsigned char *%s%d = NULL;", CB_PREFIX_BASE, f->id);

 

This line of code puts out the data variable definitions for COBOL data items defined in the LINKAGE SECTION. I claim that the above bug can be fixed by chaning the above line to:

                 output_line ("static unsigned char *%s%d = NULL;", CB_PREFIX_BASE, f->id);

 

Bob Sherry

           


reply via email to

[Prev in Thread] Current Thread [Next in Thread]