A newer version of this document is available. Customers should click here to go to the newest version.
ftrapuv, Qtrapuv
Initializes stack local variables to an unusual value to aid error detection.
Syntax
Linux: |
-ftrapuv |
Windows: |
/Qtrapuv |
Arguments
None
Default
OFF |
The compiler does not initialize local variables. |
Description
This option initializes stack local variables to an unusual value to aid error detection. Normally, these local variables should be initialized in the application. It also unmasks the floating-point invalid exception.
This option sets option -g (Linux*) and /Zi or /Z7 (Windows*), which changes the default optimization level from O2 to -O0 (Linux) or /Od (Windows). You can override this effect by explicitly specifying an O option setting.
This option sets option [Q]init snan.
If option O2 and option -ftrapuv (Linux) or /Qtrapuv (Windows) are used together, you should specify option -fp-speculation safe (Linux) or /Qfp-speculation:safe (Windows) to prevent exceptions resulting from speculated floating-point operations from being trapped.
For more details on using options -ftrapuv and /Qtrapuv with compiler option O, see the article titled Don't optimize when using -ftrapuv for uninitialized variable detection.
Another way to detect uninitialized local scalar variables is by specifying keyword uninit for option check.
IDE Equivalent
Visual Studio: Data > Initialize stack variables to an unusual value
Alternate Options
None