I've uncovered a bug in cobc's codegen when working on a test case for a different UDF bug.
In my opinion (but I'm currently out of documentation) RETURNING items of UDF should be places in WORKING-STORAGE as it is returned, but not passed by the caller.
01 PAR-OUT PIC 9.
01 PAR-IN PIC 9.
PROCEDURE DIVISION USING PAR-IN RETURNING PAR-OUT.
ADD 1 TO PAR-IN GIVING PAR-OUT END-ADD.
END FUNCTION WITHPAR.
Currently this code leads to a C compiler error (see [#57], where I've posted a quick-fix [just tested with a simple program]) which is surely a bug. Either there is a clear definition that WORKING-STORAGE items are not allowed there (which I don't think) and cobc should throw an error or items in LINKAGE-STORAGE should not be used [or be self-allocated] and we should simply delete the whole code part.
Or we use the supplied patch (tweak it if possible) and supporting both.
What do you think of this issue? Do you have any docs for UDF you can quote where RETURNING items should be located and/or samples [despite of the samples here in this board]?
Do you have any suggestions for a better patch?
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.