bug-gnucobol
[Top][All Lists]
Advanced

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

GnuCOBOL call parameter problem.


From: rdubner
Subject: GnuCOBOL call parameter problem.
Date: Thu, 4 Jun 2020 13:58:06 -0400

Enclosed is a demonstration program that shows a problem I've found.  

The output of the program is

Arrived at routine1
This should be '0x1111111111111111' and is 0x1111111111111111
This should be '0x2222222222222222' and is 0x2222222222222222
Arrived at routine2
This should be '0x3333333333333333' and is 0x3333333333333333
This should be '0x4444444444444444' but is 0x0000000000000000
Leaving routine2
Leaving routine1

This was compiled with gnucobol-3.1-dev, svn revision 3586, running on
Ubuntu 18.04.4

The program flow is this:  

1) The main() routine in main.c calls COBOL routine1 with two parameters.

2) routine1 then calls the one_parameter() C routine, in main.c, with one
parameter.

3) one_parameter then calls COBOL routine2 with two parameters.  You can see
from the output that the second parameter isn't coming through correctly.

The cause is that routine1, when it calls one_parameter(), is setting the
libcob global variable cob_call_params to 1.

So, when one_parameter then calls routine2, cob_call_params is still 1, and
so the parameter checking routine at the beginning of routine2 is setting
the second parameter to NULL.

I'm calling this a bug because routine2 is defined as USING two parameters,
and I am calling it with two parameters. It seems to me that I have a
reasonable expectation that both of those parameters will be passed.  As it
is, depending on the state of cob_call_params, the second or both of them,
or neither, might be set to NULL.

Attachment: callbug.tar.gz
Description: GNU Zip compressed data


reply via email to

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