Hi,
It appears revision 5290 caused some regression in moves to numeric edited items.
Consider the following program:
IDENTIFICATION DIVISION.
PROGRAM-ID. prog.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 W-X1 PIC S9 VALUE 4.
01 W-X2 PIC -B- VALUE SPACES.
01 W-Y1 PIC S9 VALUE -4.
01 W-Y2 PIC +B+ VALUE SPACES.
PROCEDURE DIVISION.
MOVE W-X1 TO W-X2.
DISPLAY W-X2.
MOVE W-Y1 TO W-Y2.
DISPLAY W-Y2.
STOP RUN.
With 5290, it outputs:
-4
+4
While with any earlier revision, it outputs:
4
- 4
I tried to have a look at the new optimized_move_display_to_edited function, but I believe the original author (@chaat) has a much better understanding of this code.
David,
This appears to be a bug in both the earlier revision as well as the current version.
from IBM doc...
https://www.ibm.com/docs/en/cobol-zos/6.3?topic=clause-floating-insertion-editing
from 2022 ISO standard pg 449
here is the result with the Fujitsu COBOL compiler
with my fix...
ran my build from source with this patch and it passed all the testsuite and NIST tests successfully
note that this test program should be added to the testsuite to ensure that going forward we check for regression on this.
Last edit: Chuck Haatvedt 2024-11-22
Hi Chuck,
Thank you for this patch ; that was quick ;)
I'll check that it passes the CI on our GitHub mirror (P.S: it's open to anyone, feel free to use it to check your patches).
Just to be more future-proof: can you think of any other "corner cases" of these moves to numeric edited that would be missing a test case ?
Also, checking with @sf-mensch: is this patch OK for you ?
Last edit: David Declerck 2024-11-22
So NIST is working fine with it?
Am 22. November 2024 14:28:08 MEZ schrieb David Declerck ddeclerck@users.sourceforge.net:
Related
Bugs:
#1008here is from the IBM documentation, I've not checked the 2022 draft standard...
the comma works, but I've not checked the other two, the zero and slash.
gnucobol with current patch...
with Fujitsu compiler
So perhaps this is another existing bug....
here is the result with another patch...
This now matches the output from the Fujitsu compiler.
i've attached a new version of the patch file.
Last edit: Chuck Haatvedt 2024-11-23
also testsuite #532 needs to be fixed as it is incorrect
the expected result should be
here is the patch file for run_fundamental.at
Last edit: Chuck Haatvedt 2024-11-23
Hi Chuck,
Seems there's a bit more that has been broken with these patches.
With 5285,
BLANK WHEN ZEROno longer works in some cases.This displays:
The check for zero in
optimized_move_display_to_editedmight be a bit too restrictive, since the source data may contain a sign (in the example above, the literal 0 ends up in a display field which contains00000000+).David,
here is a patch file for MOVE.C
the issue was when checking for "BLANK WHEN ZERO" was that if the sending field is signed, then we need to scan for 1 less byte. Note that the intermediate field is always created as display numeric with the same number of digits and scale as the receiving picture field. Also if the receiving field is signed then the intermediate field will always be signed separate and sign trailing.
This looks good to me, however you should confirm that and add this to the existing test in the testsuite.
Last edit: Chuck Haatvedt 2024-12-06
David,
are you working with Simon to implement the latest patch that I sent to resolve the "BLANK WHEN ZERO" issue with a signed field ?
Fixed with [r5403].
Related
Commit: [r5403]