/sdl (Enable Additional Security Checks)
Adds recommended Security Development Lifecycle (SDL) checks. These checks include extra security-relevant warnings as errors, and additional secure code-generation features.
/sdl[-]
Remarks
/sdl enables a superset of the baseline security checks provided by /GS and overrides /GS-. By default, /sdl is off. /sdl- disables the additional security checks.
Compile-time Checks
/sdl enables these warnings as errors:
Warning enabled by /sdl |
Equivalent command-line switch |
Description |
---|---|---|
/we4146 |
A unary minus operator was applied to an unsigned type, resulting in an unsigned result. |
|
/we4308 |
A negative integral constant converted to unsigned type, resulting in a possibly meaningless result. |
|
/we4532 |
Use of continue, break or goto keywords in a __finally/finally block has undefined behavior during abnormal termination. |
|
/we4533 |
Code initializing a variable will not be executed. |
|
/we4700 |
Use of an uninitialized local variable. |
|
/we4703 |
Use of a potentially uninitialized local pointer variable. |
|
/we4789 |
Buffer overrun when specific C run-time (CRT) functions are used. |
|
/we4995 |
Use of a function marked with pragma deprecated. |
|
/we4996 |
Use of a function marked as deprecated. |
Runtime checks
When /sdl is enabled, the compiler generates code to perform these checks at run time:
Enables the strict mode of /GS run-time buffer overrun detection, equivalent to compiling with #pragma strict_gs_check(push, on).
Performs limited pointer sanitization. In expressions that do not involve dereferences and in types that have no user-defined destructor, pointer references are set to a non-valid address after a call to delete. This helps to prevent the reuse of stale pointer references.
Performs class member initialization. Automatically initializes all class members to zero on object instantiation (before the constructor runs). This helps prevent the use of uninitialized data associated with class members that the constructor does not explicitly initialize.
Remarks
For more information, see Warnings, /sdl, and improving uninitialized variable detection.
To set this compiler option in the Visual Studio development environment
Open the project's Property Pages dialog box. For details, see How to: Open Project Property Pages.
Select the C/C++ folder.
On the General page, select the option from the SDL checks drop-down list.