Skip to content

Repo sync for protected CLA branch #2518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/build/reference/rtc-run-time-error-checks.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: "/RTC (Run-time error checks)"
description: "The Microsoft C/C++ compiler /RTC options for run-time error checks."
ms.date: 07/31/2020
f1_keywords: ["/rtc", "VC.Project.VCCLCompilerTool.SmallerTypeCheck", "VC.Project.VCCLCompilerTool.UninitializedVariableCheck", "VC.Project.VCCLCompilerTool.StackFrameCheck", "VC.Project.VCCLCompilerTool.BasicRuntimeChecks"]
helpviewer_keywords: ["/RTCs compiler option [C++]", "-RTC1 compiler option [C++]", "run-time errors, error checks", "-RTCu compiler option [C++]", "/RTC1 compiler option [C++]", "/RTCc compiler option [C++]", "/RTCu compiler option [C++]", "__MSVC_RUNTIME_CHECKS macro", "-RTCs compiler option [C++]", "RTCs compiler option", "RTC1 compiler option", "run-time errors, run-time checks", "run-time checks, /RTC option", "RTCu compiler option", "RTCc compiler option", "-RTCc compiler option [C++]"]
Expand Down Expand Up @@ -82,7 +83,7 @@ The `__MSVC_RUNTIME_CHECKS` preprocessor directive will be defined when you use

1. Open the project's **Property Pages** dialog box. For details, see [Set C++ compiler and build properties in Visual Studio](../working-with-project-properties.md).

1. Select the **Configuration Properties** > **C/C++** **Code Generation** property page.
1. Select the **Configuration Properties** > **C/C++** > **Code Generation** property page.

1. Modify one or both of the following properties: **Basic Runtime Checks** or **Smaller Type Check**.

Expand Down
53 changes: 26 additions & 27 deletions docs/build/reference/sdl-enable-additional-security-checks.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
title: "/sdl (Enable Additional Security Checks)"
ms.date: "11/26/2018"
description: "The Microsoft C/C++ compiler /sdl option enables recommended Security Development Lifecycle (SDL) checks and warnings."
ms.date: 10/02/2020
f1_keywords: ["VC.Project.VCCLCompilerTool.SDLCheck"]
ms.assetid: 3dcf86a0-3169-4240-9f29-e04a9f535826
---
# /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.
Enables recommended Security Development Lifecycle (SDL) checks. These checks change security-relevant warnings into errors, and set additional secure code-generation features.

## Syntax

Expand All @@ -16,53 +17,51 @@ Adds recommended Security Development Lifecycle (SDL) checks. These checks inclu

**/sdl** enables a superset of the baseline security checks provided by [`/GS`](gs-buffer-security-check.md) and overrides **`/GS-`**. By default, **`/sdl`** is off. **`/sdl-`** disables the additional security checks.

## Compile-time Checks
### Compile-time Checks

**`/sdl`** enables these warnings as errors:

|Warning enabled by /sdl|Equivalent command-line switch|Description|
|------------------------------|-------------------------------------|-----------------|
|[C4146](../../error-messages/compiler-warnings/compiler-warning-level-2-c4146.md)|/we4146|A unary minus operator was applied to an unsigned type, resulting in an unsigned result.|
|[C4308](../../error-messages/compiler-warnings/compiler-warning-level-2-c4308.md)|/we4308|A negative integral constant converted to unsigned type, resulting in a possibly meaningless result.|
|[C4532](../../error-messages/compiler-warnings/compiler-warning-level-1-c4532.md)|/we4532|Use of `continue`, `break` or `goto` keywords in a `__finally`/`finally` block has undefined behavior during abnormal termination.|
|[C4533](../../error-messages/compiler-warnings/compiler-warning-level-1-c4533.md)|/we4533|Code initializing a variable will not be executed.|
|[C4700](../../error-messages/compiler-warnings/compiler-warning-level-1-and-level-4-c4700.md)|/we4700|Use of an uninitialized local variable.|
|[C4703](../../error-messages/compiler-warnings/compiler-warning-level-4-c4703.md)|/we4703|Use of a potentially uninitialized local pointer variable.|
|[C4789](../../error-messages/compiler-warnings/compiler-warning-level-1-c4789.md)|/we4789|Buffer overrun when specific C run-time (CRT) functions are used.|
|[C4995](../../error-messages/compiler-warnings/compiler-warning-level-3-c4995.md)|/we4995|Use of a function marked with pragma [`deprecated`](../../preprocessor/deprecated-c-cpp.md).|
|[C4996](../../error-messages/compiler-warnings/compiler-warning-level-3-c4996.md)|/we4996|Use of a function marked as [`deprecated`](../../cpp/deprecated-cpp.md).|
| Warning enabled by /sdl | Equivalent command-line switch | Description |
|--|--|--|
| [C4146](../../error-messages/compiler-warnings/compiler-warning-level-2-c4146.md) | /we4146 | A unary minus operator was applied to an unsigned type, resulting in an unsigned result. |
| [C4308](../../error-messages/compiler-warnings/compiler-warning-level-2-c4308.md) | /we4308 | A negative integral constant converted to unsigned type, resulting in a possibly meaningless result. |
| [C4532](../../error-messages/compiler-warnings/compiler-warning-level-1-c4532.md) | /we4532 | Use of `continue`, `break`, or `goto` keywords in a `__finally`/`finally` block has undefined behavior during abnormal termination. |
| [C4533](../../error-messages/compiler-warnings/compiler-warning-level-1-c4533.md) | /we4533 | Code initializing a variable will not be executed. |
| [C4700](../../error-messages/compiler-warnings/compiler-warning-level-1-and-level-4-c4700.md) | /we4700 | Use of an uninitialized local variable. |
| [C4703](../../error-messages/compiler-warnings/compiler-warning-level-4-c4703.md) | /we4703 | Use of a potentially uninitialized local pointer variable. |
| [C4789](../../error-messages/compiler-warnings/compiler-warning-level-1-c4789.md) | /we4789 | Buffer overrun when specific C run-time (CRT) functions are used. |
| [C4995](../../error-messages/compiler-warnings/compiler-warning-level-3-c4995.md) | /we4995 | Use of a function marked with pragma [`deprecated`](../../preprocessor/deprecated-c-cpp.md). |
| [C4996](../../error-messages/compiler-warnings/compiler-warning-level-3-c4996.md) | /we4996 | Use of a function marked as [`deprecated`](../../cpp/deprecated-cpp.md). |

## Runtime checks
### Runtime checks

When **`/sdl`** is enabled, the compiler generates code to perform these checks at run time:
When **`/sdl`** is enabled, the compiler generates code that does 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.
- Does limited pointer sanitization. In expressions that don't 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 sanitization helps to prevent the reuse of stale pointer references.

- Performs class member pointer initialization. Automatically initializes class members of pointer type to **`nullptr`** on object instantiation (before the constructor runs). This helps prevent the use of uninitialized pointers that the constructor does not explicitly initialize. The compiler-generated member pointer initialization is called as long as:
- Initializes class member pointers. Automatically initializes class members of pointer type to **`nullptr`** on object instantiation (before the constructor runs). It helps prevent the use of uninitialized pointers that the constructor doesn't explicitly initialize. The compiler-generated member pointer initialization is called as long as:

- The object is not allocated using a custom (user defined) `operator new`
- The object isn't allocated using a custom (user defined) `operator new`

- The object is not allocated as part of an array (for example `new A[x]`)
- The object isn't allocated as part of an array (for example `new A[x]`)

- The class is not managed or imported
- The class isn't managed or imported

- The class has a user-defined default constructor.

To be initialized by the compiler-generated class initialization function, a member must be a pointer, and not a property or constant.

## Remarks

For more information, see [Warnings, /sdl, and improving uninitialized variable detection](https://cloudblogs.microsoft.com/microsoftsecure/2012/06/06/warnings-sdl-and-improving-uninitialized-variable-detection/).
For more information, see [Warnings, /sdl, and improving uninitialized variable detection](https://www.microsoft.com/security/blog/2012/06/06/warnings-sdl-and-improving-uninitialized-variable-detection/).

#### To set this compiler option in the Visual Studio development environment
### To set this compiler option in the Visual Studio development environment

1. Open the project's **Property Pages** dialog box. For details, see [Set C++ compiler and build properties in Visual Studio](../working-with-project-properties.md).

1. Select the **C/C++** folder.
1. Select the **Configuration Properties** > **C/C++** > **General** property page.

1. On the **General** page, select the option from the **SDL checks** drop-down list.
1. Set the **SDL checks** property by using the property drop-down control. Choose **OK** or **Apply** to save your changes.

## See also

Expand Down
79 changes: 39 additions & 40 deletions docs/c-language/c-enumeration-declarations.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,65 @@
---
title: "C Enumeration Declarations"
ms.date: "11/04/2016"
title: "C enumeration declarations"
description: "Enumeration declarations in the C programming language."
ms.date: 10/02/2020
helpviewer_keywords: ["declarations, enumerations", "define directive (#define), alternative to", "enumerators, declaring", "#define directive, alternative to", "named constants, enumeration declarations", "declaring enumerations"]
ms.assetid: bd18f673-4dda-4bc1-92fd-d1ce10074910
---
# C Enumeration Declarations
# C enumeration declarations

An enumeration consists of a set of named integer constants. An enumeration type declaration gives the name of the (optional) enumeration tag and defines the set of named integer identifiers (called the "enumeration set," "enumerator constants," "enumerators," or "members"). A variable with enumeration type stores one of the values of the enumeration set defined by that type.
An enumeration consists of a set of named integer constants. An enumeration type declaration gives the name of the (optional) enumeration tag. And, it defines the set of named integer identifiers (called the *enumeration set*, *enumerator constants*, *enumerators*, or *members*). A variable of the enumeration type stores one of the values of the enumeration set defined by that type.

Variables of **`enum`** type can be used in indexing expressions and as operands of all arithmetic and relational operators. Enumerations provide an alternative to the `#define` preprocessor directive with the advantages that the values can be generated for you and obey normal scoping rules.

In ANSI C, the expressions that define the value of an enumerator constant always have **`int`** type; thus, the storage associated with an enumeration variable is the storage required for a single **`int`** value. An enumeration constant or a value of enumerated type can be used anywhere the C language permits an integer expression.
In ANSI C, the expressions that define the value of an enumerator constant always have **`int`** type. That means the storage associated with an enumeration variable is the storage required for a single **`int`** value. An enumeration constant or a value of enumerated type can be used anywhere the C language permits an integer expression.

## Syntax

*enum-specifier*:<br/>
&nbsp;&nbsp;&nbsp;&nbsp;**`enum`** *identifier*<sub>opt</sub> **{** *enumerator-list* **}**<br/>
&nbsp;&nbsp;&nbsp;&nbsp;**`enum`** *identifier*
*`enum-specifier`*:\
&emsp;**`enum`** *`identifier`*<sub>opt</sub> **`{`** *`enumerator-list`* **`}`**\
&emsp;**`enum`** *`identifier`*

The optional *identifier* names the enumeration type defined by *enumerator-list*. This identifier is often called the "tag" of the enumeration specified by the list. A type specifier of the form
*`enumerator-list`*:\
&emsp;*`enumerator`*\
&emsp;*`enumerator-list`* **`,`** *`enumerator`*

```
*`enumerator`*:\
&emsp;*`enumeration-constant`*\
&emsp;*`enumeration-constant`* **`=`** *`constant-expression`*

*`enumeration-constant`*:\
&emsp;*`identifier`*

The optional *`identifier`* names the enumeration type defined by *`enumerator-list`*. This identifier is often called the "tag" of the enumeration specified by the list. A type specifier declares `identifier` to be the tag of the enumeration specified by the *`enumerator-list`* nonterminal, as seen here:

```C
enum identifier
{
enumerator-list
// enumerator-list
}
```

declares *identifier* to be the tag of the enumeration specified by the *enumerator-list* nonterminal. The *enumerator-list* defines the "enumerator content." The *enumerator-list* is described in detail below.

If the declaration of a tag is visible, subsequent declarations that use the tag but omit *enumerator-list* specify the previously declared enumerated type. The tag must refer to a defined enumeration type, and that enumeration type must be in current scope. Since the enumeration type is defined elsewhere, the *enumerator-list* does not appear in this declaration. Declarations of types derived from enumerations and **`typedef`** declarations for enumeration types can use the enumeration tag before the enumeration type is defined.

## Syntax

*enumerator-list*:<br/>
&nbsp;&nbsp;&nbsp;&nbsp;*enumerator*<br/>
&nbsp;&nbsp;&nbsp;&nbsp;*enumerator-list* **,** *enumerator*

*enumerator*:<br/>
&nbsp;&nbsp;&nbsp;&nbsp;*enumeration-constant*<br/>
&nbsp;&nbsp;&nbsp;&nbsp;*enumeration-constant* **=** *constant-expression*
The *`enumerator-list`* defines the members of the enumeration set.

*enumeration-constant*:<br/>
&nbsp;&nbsp;&nbsp;&nbsp;*identifier*
If the declaration of a tag is visible, later declarations that use the tag but omit *`enumerator-list`* specify the previously declared enumerated type. The tag must refer to a defined enumeration type, and that enumeration type must be in current scope. Since the enumeration type is defined elsewhere, the *`enumerator-list`* doesn't appear in this declaration. Declarations of types derived from enumerations and **`typedef`** declarations for enumeration types can use the enumeration tag before the enumeration type is defined.

Each *enumeration-constant* in an *enumeration-list* names a value of the enumeration set. By default, the first *enumeration-constant* is associated with the value 0. The next *enumeration-constant* in the list is associated with the value of ( *constant-expression* + 1 ), unless you explicitly associate it with another value. The name of an *enumeration-constant* is equivalent to its value.
Each *`enumeration-constant`* in an *`enumerator-list`* names a value of the enumeration set. By default, the first *`enumeration-constant`* is associated with the value 0. The next *`enumeration-constant`* in the list is associated with the value of ( *`constant-expression`* + 1 ), unless you explicitly associate it with another value. The name of an *`enumeration-constant`* is equivalent to its value.

You can use *enumeration-constant = constant-expression* to override the default sequence of values. Thus, if *enumeration-constant = constant-expression* appears in the *enumerator-list*, the *enumeration-constant* is associated with the value given by *constant-expression*. The *constant-expression* must have **`int`** type and can be negative.
You can use *`enumeration-constant`* = *`constant-expression`* to override the default sequence of values. That is, if *`enumeration-constant`* = *`constant-expression`* appears in the *`enumerator-list`*, the *`enumeration-constant`* is associated with the value given by *`constant-expression`*. The *`constant-expression`* must have **`int`** type and can be negative.

The following rules apply to the members of an enumeration set:

- An enumeration set can contain duplicate constant values. For example, you could associate the value 0 with two different identifiers, perhaps named `null` and `zero`, in the same set.
- An enumeration set can contain duplicate constant values. For example, you could associate the value 0 with two different identifiers, for example, members named `null` and `zero`, in the same set.

- The identifiers in the enumeration list must be distinct from other identifiers in the same scope with the same visibility, including ordinary variable names and identifiers in other enumeration lists.
- The identifiers in the enumeration list must be distinct from other identifiers in the same scope with the same visibility. That includes ordinary variable names and identifiers in other enumeration lists.

- Enumeration tags obey the normal scoping rules. They must be distinct from other enumeration, structure, and union tags with the same visibility.

## Examples

These examples illustrate enumeration declarations:

```
```C
enum DAY /* Defines an enumeration type */
{
saturday, /* Names day and declares a */
Expand All @@ -77,21 +76,21 @@ The value 0 is associated with `saturday` by default. The identifier `sunday` is

In this example, a value from the set `DAY` is assigned to the variable `today`.

```
```C
enum DAY today = wednesday;
```

Note that the name of the enumeration constant is used to assign the value. Since the `DAY` enumeration type was previously declared, only the enumeration tag `DAY` is necessary.
The name of the enumeration constant is used to assign the value. Since the `DAY` enumeration type was previously declared, only the enumeration tag `DAY` is necessary.

To explicitly assign an integer value to a variable of an enumerated data type, use a type cast:

```
```C
workday = ( enum DAY ) ( day_value - 1 );
```

This cast is recommended in C but is not required.
This cast is recommended in C but isn't required.

```
```C
enum BOOLEAN /* Declares an enumeration data type called BOOLEAN */
{
false, /* false = 0, true = 1 */
Expand All @@ -103,20 +102,20 @@ enum BOOLEAN end_flag, match_flag; /* Two variables of type BOOLEAN */

This declaration can also be specified as

```
```C
enum BOOLEAN { false, true } end_flag, match_flag;\
```

or as

```
```C
enum BOOLEAN { false, true } end_flag;
enum BOOLEAN match_flag;
```

An example that uses these variables might look like this:

```
```C
if ( match_flag == false )
{
.
Expand All @@ -128,7 +127,7 @@ if ( match_flag == false )

Unnamed enumerator data types can also be declared. The name of the data type is omitted, but variables can be declared. The variable `response` is a variable of the type defined:

```
```C
enum { yes, no } response;
```

Expand Down
1 change: 1 addition & 0 deletions docs/c-runtime-library/internationalization.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ms.assetid: ee536a04-3558-4729-8e10-6dabcde055fd
# Internationalization

The Microsoft runtime library provides many routines that you can use to customize your app for international markets such as:

- [locale-related routines](../c-runtime-library/locale.md)
- wide-character routines
- multibyte-character routines
Expand Down
Loading