C/C++ Programmer's Guide (G06.25+)
Compiler Pragmas
HP C/C++ Programmer’s Guide for NonStop Systems—429301-008
13-74
OVERFLOW_TRAPS
The pragma default settings are:
Usage Guidelines
•
The OVERFLOW_TRAPS pragma can be entered on the compiler RUN command
line or in the source text. It can also be specified with the -Woverflow_traps
flag of the c89 utility.
•
Multiple pragmas can be placed in the source code to turn on and off the
generation of code that traps on arithmetic overflow.
•
The OVERFLOW_TRAPS pragma in C mimics the overflow trapping code in pTAL
and the trapping behavior of the TNS C compiler. Code that traps on integer
overflow is generated only for signed arithmetic operations. Unsigned arithmetic
operations always truncate. Thus, if your code uses only unsigned arithmetic
operations, the code does not trap on integer overflow.
•
For details on arithmetic overflow and signals, see the Guardian Programmer’s
Guide
Example
#pragma NOOVERFLOW_TRAPS
void NoTraps (void) {
/* No trapping code generated */
}
#pragma OVERFLOW_TRAPS
void Traps (void) {
/* Generates trapping code */
}
#pragma NOOVERFLOW_TRAPS
/* Again, no trapping code generated */
SYSTYPE GUARDIAN SYSTYPE OSS
TNS C compiler N.A. N.A.
G-series TNS c89 utility N.A. N.A.
TNS/R native C and C++ compilers NOOVERFLOW_TRAPS NOOVERFLOW_TRAPS
Native c89 utility NOOVERFLOW_TRAPS NOOVERFLOW_TRAPS
TNS/E native C and C++ compilers NOOVERFLOW_TRAPS NOOVERFLOW_TRAPS