Skip to content

Commit a965cfe

Browse files
authored
Merge pull request #2691 from corob-msft/cr-1918
New /Zc:rvalueCast property page entry per 1918
2 parents 9ca7634 + 7c01350 commit a965cfe

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

docs/build/reference/zc-rvaluecast-enforce-type-conversion-rules.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
---
22
title: "/Zc:rvalueCast (Enforce type conversion rules)"
3-
ms.date: "03/06/2018"
3+
ms.date: "02/18/2020"
44
f1_keywords: ["rvaluecast", "/Zc:rvalueCast", "VC.Project.VCCLCompilerTool.EnforceTypeConversionRules"]
55
helpviewer_keywords: ["-Zc compiler options (C++)", "rvaluecast", "Enforce type conversion rules", "/Zc compiler options (C++)", "Zc compiler options (C++)"]
66
ms.assetid: 7825277d-e565-4c48-b0fb-76ac0b0c6e38
77
---
88
# /Zc:rvalueCast (Enforce type conversion rules)
99

10-
When the **/Zc:rvalueCast** option is specified, the compiler correctly identifies an rvalue reference type as the result of a cast operation in accordance with the C++11 standard. When the option is not specified, the compiler behavior is the same as in Visual Studio 2012.
10+
When the **`/Zc:rvalueCast`** option is specified, the compiler correctly identifies an rvalue reference type as the result of a cast operation. Its behavior conforms to the C++11 standard. When the option is unspecified, the compiler behavior is the same as in Visual Studio 2012.
1111

1212
## Syntax
1313

14-
> **/Zc:rvalueCast**[**-**]
14+
> **`/Zc:rvalueCast`**\
15+
> **`/Zc:rvalueCast-`**
1516
1617
## Remarks
1718

18-
If **/Zc:rvalueCast** is specified, the compiler follows section 5.4 of the C++11 standard and treats only cast expressions that result in non-reference types and cast expressions that result in rvalue references to non-function types as rvalue types. By default, or if **/Zc:rvalueCast-** is specified, the compiler is non-conformant and treats all cast expressions that result in rvalue references as rvalues. For conformance and to eliminate errors in the use of casts, we recommend that you use **/Zc:rvalueCast**.
19+
If **`/Zc:rvalueCast`** is specified, the compiler follows section 5.4 of the C++11 standard and treats only cast expressions that result in non-reference types and cast expressions that result in rvalue references to non-function types as rvalue types. By default, or if **`/Zc:rvalueCast-`** is specified, the compiler is non-conforming, and treats all cast expressions that result in rvalue references as rvalues. For conformance, and to eliminate errors in the use of casts, we recommend that you use **`/Zc:rvalueCast`**.
1920

20-
By default, **/Zc:rvalueCast** is off (**/Zc:rvalueCast-**). The [/permissive-](permissive-standards-conformance.md) compiler option implicitly sets this option, but it can be overridden by using **/Zc:rvalueCast-**.
21+
By default, **`/Zc:rvalueCast`** is off (**`/Zc:rvalueCast-`**). The [/permissive-](permissive-standards-conformance.md) compiler option implicitly sets this option, but it can be overridden by using **`/Zc:rvalueCast-`**.
2122

22-
Use **/Zc:rvalueCast** if you pass a cast expression as an argument to a function that takes an rvalue reference type. The default behavior causes compiler error [C2664](../../error-messages/compiler-errors-2/compiler-error-c2664.md) when the compiler incorrectly determines the type of the cast expression. This example shows a compiler error in correct code when **/Zc:rvalueCast** is not specified:
23+
Use **`/Zc:rvalueCast`** if you pass a cast expression as an argument to a function that takes an rvalue reference type. The default behavior causes compiler error [C2664](../../error-messages/compiler-errors-2/compiler-error-c2664.md) when the compiler incorrectly determines the type of the cast expression. This example shows a compiler error in correct code when **`/Zc:rvalueCast`** isn't specified:
2324

2425
```cpp
2526
// Test of /Zc:rvalueCast
@@ -57,7 +58,7 @@ struct Test1 {
5758
};
5859
```
5960
60-
The default compiler behavior may not report error C2102 when appropriate. In this example, the compiler does not report an error if the address of an rvalue created by an identity cast is taken when **/Zc:rvalueCast** is not specified:
61+
The default compiler behavior may not report error C2102 when appropriate. In this example, the compiler doesn't report an error if the address of an rvalue created by an identity cast is taken when **`/Zc:rvalueCast`** is unspecified:
6162
6263
```cpp
6364
int main() {
@@ -74,10 +75,10 @@ For more information about conformance issues in Visual C++, see [Nonstandard Be
7475

7576
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).
7677

77-
1. Select the **Configuration Properties** > **C/C++** > **Command Line** property page.
78+
1. Select the **Configuration Properties** > **C/C++** > **Language** property page.
7879

79-
1. Modify the **Additional Options** property to include **/Zc:rvalueCast** and then choose **OK**.
80+
1. Set the **Enforce type conversion rules** property to **`/Zc:rvalueCast`** or **`/Zc:rvalueCast-`**. Choose **OK** or **Apply** to save your changes.
8081

8182
## See also
8283

83-
[/Zc (Conformance)](zc-conformance.md)<br/>
84+
[/Zc (Conformance)](zc-conformance.md)

0 commit comments

Comments
 (0)