PDA

View Full Version : A bit of fun with bugs


FSS
12-18-2002, 05:11 AM
By accident I found the following (Major?) bug in AcuCobol:

Let make a quiz out of it (hope you're in for a little joke) ;)
* what does the following code display, and does it ever end?

--- cut here ---------------------------

identification division.

program-id. bugtest.
author. Frans Smits Software B.V. (Leon Arnst).

procedure division.

main section.
perform until 5 < 1
display 5
subtract 1 from 5
end-perform.

exit program.
stop run.

--- cut here ----------------------------

Sounds funny, but the answer is:
Yes, it ends after displaying
5
4
3
2
1
:)

FNAPrince
12-26-2002, 09:45 AM
According to section 6.4.1 of the Reference Manual (Book 3) in paragraph #3, the result of the 'subtract' verb is stored in a temporary data item created by the compiler.

This sample program seems to show that the 'temporary' data item is named '5', which is why the perform can end.

Great Stuff, Frans!