|
From: | Robert Sherry |
Subject: | [open-cobol-list] Bug Report and Bug Fix |
Date: | Sat Apr 1 06:32:03 2006 |
With
the March release of the Open Source COBOL Compiler, the following program does
not produce the expected output: ID DIVISION.
PROGRAM-ID. ADD1.
ENVIRONMENT DIVISION. CONFIGURATION SECTION. INPUT-OUTPUT SECTION. FILE-CONTROL. DATA DIVISION. FILE SECTION. WORKING-STORAGE
SECTION. 01 C1 PIC 9(4)
USAGE IS COMP-5. PROCEDURE DIVISION. MOVE 100 TO C1. DISPLAY C1 SUBTRACT 10 FROM
C1. DISPLAY C1 SUBTRACT 9 FROM
C1. DISPLAY C1 GOBACK. Instead of subtracting from the data item C1, the program
adds to the variable C1. If C1 had been declared as COMP then the above program
would have worked. Please consider the file codegen.h. This file defines the routine
cob_addsub_u16_binary. This routine performs either an addition or a
subtraction on a data item. In certain cases, before the addition or subtract
can be done, the data item needs to be converted. For the case that the macro WORDS_BIGENDIAN
is def defined and COB_FIELD_BINARY_SWAP (f) is off the routine only does an
add. This can be fixed by replacing the statement: *(unsigned short
*)p += val; with: if (!addsub) {
*(unsigned short *)p += val; } else {
*(unsigned short *)p -= val; } I claim that the following routines also have the same
problem: cob_addsub_s16_binary, cob_addsub_u32_binary,
cob_addsub_s32_binary, cob_addsub_u64_binary, cob_addsub_s64_binary I would be happy to check my change in to SCCS system, if
that is the appropriate thing to do. |
[Prev in Thread] | Current Thread | [Next in Thread] |