Checking the Floating-point Stack State

On systems based on the IA-32 or Intel® 64 architectures, when an application calls a function that returns a floating-point value, the returned floating-point value is supposed to be on the top of the floating-point stack. If the return value is not used, the compiler must pop the value off of the floating-point stack in order to keep the floating-point stack in correct state.

If the application calls a function, either without defining or incorrectly defining the function's prototype, the compiler does not know whether the function must return a floating-point value, and the return value is not popped off of the floating-point stack if it is not used. This can cause the floating-point stack to overflow.

The overflow of the stack results in two undesirable situations:

For systems based on the IA-32 and Intel® 64 architectures, the -fpstkchk (Linux* and Mac OS* X) or /Qfpstkchk (Windows*) option checks whether a program makes a correct call to a function that should return a floating-point value. If an incorrect call is detected, the option places a code that marks the incorrect call in the program. The -fpstkchk (Linux and Mac OS X) or /Qfpstkchk (Windows) option marks the incorrect call and makes it easy to find the error.

Note

This option causes significant code generation after every function/subroutine call to insure a proper state of a floating-point stack and slows down compilation. It is meant only as a debugging aid for finding floating point stack underflow/overflow problems, which can be otherwise hard to find.