In Visual C++, you can use run-time error checks to catch common run-time errors such as:
To enable run-time error checks in a debug build, use the /RTC option and link with the debug version of a C run-time library (/MDd, for example). You can modify run-time error check behavior with the run-time_checks pragma.
You cannot use /RTC with an optimized (/O) build. A compiler error results. If you use a run-time_checks pragma in an optimized build, the pragma has no effect.
When you debug a program with run-time error 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 Handling Exceptions.
Note Run-time error checking tracks memory allocation and deallocation only if the allocation and deallocation is done with C allocators (malloc, calloc, realloc, and free) or global C++ allocators (new, new[], delete, and delete[]). Memory leak and pointer type checking also depend on the proper use of these allocators and deallocators. If you use other functions for allocating and deallocating memory, you cannot count on runtime error checking to catch these problems unless you write your own reporting functions.
What do you want to know more about?
Debugging Your Program | /RTC compiler option | #pragma run-time_checks | Run-Time Error Checks Function Reference | RTC sample