Cobol WTF still happening
-
This is an extract from an actual business application which utterly baffled the perpetrator:
01 HUGE-ARRAY PIC X(20) OCCURS 0 TO 2000000 DEPENDING ON ODO-VALUE.
01 ODO-VALUE PIC 9(6).
MOVE 1000000 TO ODO-VALUE.MOVE 'Initial value' to HUGE-ARRAY(1).
(Program terminates with "array subscrpt out of bounds" error.)
Boys and girls, can you say "move truncation rules"?
Lord Parity
Last Count of Register
-
The Real WTF(tm) is that Cobol is still happening ;-) SCNR
-
Don't tell me, let me guess. He translated it from C, referring to his 1985 edition of "How To Translate IBM PC Turbo C Programs to COBOL".
"An 'int' is a 16-bit value, and therefore the COBOL equivalent is 'PIC 9(6)'."
-
Actually, I think he made the array bigger -- a lot bigger and didn't think beyond the array declaration. He was on email for two days with tech support before a coworker of his spotted the 9(6) problem on the line above the array.