This documentation is archived and is not being maintained.

Using Native Run-Time Checks

In Visual C++, you can use native run-time checks to catch common run-time errors such as:

  • Stack pointer corruption.
  • Overruns of local arrays.
  • Stack corruption.
  • Dependencies on uninitialized local variables.
  • Loss of data on an assignment to a shorter variable.

To enable native run-time checks in a debug build

  • Use the /RTC option and link with the debug version of a C run-time library (/MDd, for example).

To modify native run-time check behavior

  • Use the runtime_checks pragma.

You cannot use /RTC with an optimized (/O) build. A compiler error results. If you use a runtime_checks pragma in an optimized build, the pragma has no effect.

When you debug a program with run-time checks enabled, the default action is for the program to stop and break to the debugger when a run-time error occurs. You can change this default behavior for any run-time check. For details, see Changing How the Debugger Handles Exceptions.

Other topics in this section provide information on:

See Also

Debugging Your Program | runtime_checks | Run-Time Error Checks Function Reference | RTC sample