HP Fortran Programmer's Guide (B3908-90031; September 2011)

Debugging
Handling runtime exceptions
Chapter 4 125
Division by zero
Overflow
Underflow
The +FP option also enables the trap for the inexact operation exception. For detailed descriptions of
these exceptions, refer to the HP-UX Floating-Point Guide.
Unlike the +fp_exception option, the +FP option includes a flags argument by which you can
enable specific exceptions.
The +FP option can also be used to enable fast underflow on systems that support it (chiefly PA2.0
systems).
Both options cause your program to abort when it traps the exception. However, +fp_exception
identifies the type of the exception that occurred and the virtual address of the statement that triggered
it. Also, +FP causes a core dump; +fp_exception does not.
You can also trap floating-point exceptions with the ON statement. Although the ON statement requires you to
modify source code, it enables you to write trap procedures so that your program can recover from
exceptions. For more information about using the ON statement, see Chapter 5, “Using the ON statement,”
on page 127.
Refer to the HP Fortran Programmer’s Reference, for detailed information about the +FP and
+fp_exception options. Also, the HP-UX Floating-Point Guide has a useful discussion of both
options and includes detailed information on floating-point exceptions and how to handle them.
Illegal instruction exception
An illegal instruction exception occurs when a program attempts to execute a bit pattern that is not an
op-code. A common cause of this exception is an overwritten stack. If a program overwrites the part of the
stack that holds the return address, the new (and bad) address may cause execution control to jump to a
memory location that contains data or some other nonexecutable bit pattern. The attempt to execute this
location will result in an illegal instruction exception.
This exception can also occur if your program is linked to a bad library, especially if the library contains
code that was written in assembler or if it was corrupted during a file transfer.
This exception may indicate a compiler error. If you cannot find the cause of this exception in your code,
contact your HP support representative.
Segmentation violation exception
Before a program starts to execute, it is allocated a memory segment, which defines the area of memory that
it can use. If the program attempts to access a memory location outside its segment, the operating system
will raise the SIGSEGV signal, indicating a segmentation violation or memory fault.