The following program exhibits strange behavior.
The fourth DISPLAYstatement, in which I commented out the two "END-DISPLAY" clause (which are not required by GnuCOBOL syntax), behaves strangely.
The program doesn't execute the "NOT ON EXCEPTION" statement but terminates without reporting errors.
The NOT ON EXCEPTION clause should still terminate what is included in the previous ON EXCEPTION clause.
I believe this can be classified as a BUG.
>>SOURCE FREE
IDENTIFICATION DIVISION.
PROGRAM-ID. TESTDISPLAY01.
PROCEDURE DIVISION.
DISPLAY ' INIT' AT 0101 BACKGROUND-COLOR 2 FOREGROUND-COLOR 1 WITH ERASE EOS
display '01 ... 1234567890' AT 0302 BACKGROUND-COLOR 6 FOREGROUND-COLOR 1
on exception display 'EXCEPTION 1' AT 0502 end-display
not on exception display 'NOT ON EXCEPTION 1' AT 0702 end-display
end-display
display ' POST DISPLAY 1 ' AT 0902 BACKGROUND-COLOR 7 FOREGROUND-COLOR 1
accept omitted AT 1001
*> ***************************************************************************
*> FOLLOWING DISPLAY HAS STRANGE BEHAVIOR. "not on exception" is NOT EXECUTED.
*> BUT PROGRAM ENDS HERE !!! NORMAL END WITHOUT ERRORS !!!
*> ***************************************************************************
display '02 ... 1234567890' AT 1202 BACKGROUND-COLOR 6 FOREGROUND-COLOR 1
on exception display 'EXCEPTION 2' AT 1402 *> end-display
not on exception display 'NOT ON EXCEPTION 2' AT 1602 *> end-display
end-display
*> end-display *> With these two END-DISPLAY it works correctly
*> end-display
display ' POST DISPLAY 2 ' AT 1802 BACKGROUND-COLOR 7 FOREGROUND-COLOR 1 *> NOT EXECUTED
accept omitted AT 2001 *> NOT EXCEUTED
goback.
I don't think that this is a bug, note that the "not on exception is not part of the following statement. This is an end of scope scenario. Find the end of scope on each of the statements in your program. This is a good example of coding a "." at the end of each independent code statement would have resolved the issue.
it is part of this statement
For example.... Note that I added a period (hard end of scope) at the end of what appears to each independent statement.
Note that MF does not support the exception part together with AT at all; if you remove all of those then it still doesn't compile...
Nor does ACUCOBOL - but if you rewrite that to use CALL then we can compare the results with the DISPLAY and also to the CALL scoping of MF and ACU.
Last edit: Simon Sobisch 2026-03-11