IBM Enterprise COBOL
ID DIVISION.
PROGRAM-ID. ERRMSG.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A PIC 9 VALUE ZERO.
PROCEDURE DIVISION.
ADD 1 TO A
GOBACK
.
Here's a short program. It obviously does nothing but add one to the field A.
However, toss it into the compiler, and... http://www-01.ibm.com/support/docview.wss?uid=swg21156178
You can generate a complete listing of compiler diagnostic messages with their >message numbers, severities, and text by compiling
a program that has program-name ERRMSG.
You can code just the PROGRAM-ID paragraph, as shown below, and omit the rest >of the program.
The key is to have errmsg
as the PROGRAM-ID
. No other code is required. The code in my example is just to convince that it is a real program which produces no output.
This is the example IBM show in the link:
Identification Division.
Program-ID. ErrMsg.
Indeed, this is enough:
Program-ID. ErrMsg.
Or this:
Program-ID. ErrMsg.
The quick brown fox jumped over the
lazy dog, or any other text you like.
This is an example of the output: http://www-01.ibm.com/support/docview.wss?uid=swg21156178&aid=1
When the compiler gets to errmsg. (note the full-stop/period, which doesn't have to be immediately after errmsg, but must exist after it somewhere in the source) it knows what is needed, reads to the end of the source and then produces the listing, including the description of the format and information contained in the error messages, and all the messages themselves.
As a curiosity, you can try this:
Program-ID. ErrMsg
This time no full-stop/period is encountered before the end of the source is reached, and a (very) minor compiler bug is revealed, as the compiler continues reading, and abends (ends abnormally, crashes) with an S001 Reason Code 5 and
IEC020I GET ISSUED AFTER END-OF-FILE
No IBM Mainframe COBOL has ever separately documented its error messages in an actual manual.
1
I'm closing this question because, by community consensus, underhanded challenges are no longer welcome on the site.
– Alex A. – 2016-04-15T03:59:18.2703I don't think this challenge is objectively measurable. How "unexpected" is "unexpected enough"? – Martin Ender – 2014-05-31T16:28:19.980
1I think this is more or less a dupe of the "Print an unexpected obscenity" question which has now been deleted so I can't find the link. That one was also an [tag:underhanded] about unexpectedly printing a word, with the constraint that it had to be an insult – None – 2014-05-31T17:32:17.457