Run-time Error Checking Options

-check=options

Generates various run-time checks. options is either a single option or a comma-separated list of options (no spaces allowed) from the following list.

These options are not valid in FORTRAN.

all

Turns on all checks.

assignbound

Checks the value in the range of the type when assigning a value to a variable or field which is a small integral type such as a bit field.

bounds

Checks array bound indices.

memory

Causes the compiler to generate extra code to verify every load or store involving a pointer which may point to memory returned by malloc() and its related functions. This option also causes a special version of those library routines to be linked.

(This option differs from -check=alloc because -check=alloc only links the special library, but does not cause the compiler to generate extra code.)

The verification is performed by reading the memory location to which the pointer points and comparing the contents to a special value. If the memory contains the special value, a library routine, __ptrchk(), is called with the address of the memory location. If that address is not within the set of legal addresses currently allocated to the program by malloc, a runtime error will occur.

This check is effective for detecting use of pointers which have been incremented past an allocated buffer.

nilderef

Generates an error message for dereferences of null pointers.

switch

Generates a warning if the case/switch expression does not match any of the case labels. This does not apply when a default case label is used or when the case statement is enclosed in an if-then construct.

usevariable

Generates a warning message during compilation of a function containing any local variables that are read before being written.

watch

Allows the MULTI debugger to set up one fast watchpoint. See the watchpoint command in the MULTI Reference Manual.

zerodivide

Generates an error message indicating that a divide by zero occurred and then terminates the program execution.

To turn off any of these options, simply precede the option with no. You can also use this to turn on every option except the indicated flag. For example, to turn on all checks except zerodivide, enter:

-check=all,nozerodivide

The following table lists output error messages when the run-time error checking is enabled. Run-time error checking requires additional code, which increases the size and reduces the speed of the program, but the convenience of automatic checking can be very valuable during debugging.

Some messages are considered fatal errors and cause the program to exit with the specified status. Other messages are warnings and will not cause the program to terminate. However, these warnings can change the eventual exit status.


Previous

Next



Copyright © 1999, Green Hills Software. All rights reserved.