HP 3000 Manuals

Parameter Checking [ HP COBOL II/XL Programmer's Guide ] MPE/iX 5.0 Documentation


HP COBOL II/XL Programmer's Guide

Parameter Checking 

When your COBOL program calls an intrinsic, the compiler tries to match
information about the type and alignment for each actual parameter.  If
this is not possible, the compiler issues an error message.

When your program calls a subprogram, the actual parameter list that your
program passes is checked at link[REV BEG] or load[REV END] time against
the formal parameter list of the subprogram for the following:

   *   The number of parameters.

   *   The parameter alignment.

   *   The types of parameters (if by value).

Each actual parameter must be of the same type as its corresponding
formal parameter.  The program file specifies the type of each formal
parameter, and if the call is by value, the linker issues an error
message if the corresponding actual parameter is not of that type.

All addresses on Series 900 machines are byte-addressed.  An address that
is divisible by two is halfword-aligned.  An address that is divisible by
four is word-aligned (and also halfword-aligned, since it is also
divisible by two).  An actual parameter and its formal counterpart must
be aligned the same.  Parameter alignment is checked at the following
three times:

   1.  When the calling program is compiled.

       If the calling program is compiled with the control option
       OPTFEATURES = CALLALIGNED, the compiler issues an error message
       whenever a parameter in the CALL is not word-aligned.

       If the calling program is compiled with the control option
       OPTFEATURES = CALLALIGNED16, the compiler issues an error message
       whenever a parameter in the CALL is not halfword-aligned.
       [REV BEG]

   2.  At link or load time.

       The linker or loader compares the alignments specified by the
       calling program and the called program.  If alignments for the
       same parameter are different, the linker or loader issues an error
       message.[REV END]

   3.  At execution time.

       If an actual and formal parameter are not aligned the same, this
       error is trapped (if possible) or the program results are
       unpredictable.  The control option BOUNDS in the called program
       turns on the traps that detect this problem.

The number of parameters in the actual and formal parameter lists[REV
BEG] must be the same.  The linker or loader issues an error message if
they are not.[REV END]



MPE/iX 5.0 Documentation