Skip to content

Commit aa179cd

Browse files
author
Colin Robertson
committed
Partial draft
1 parent a54a9d0 commit aa179cd

2 files changed

Lines changed: 39 additions & 9 deletions

File tree

docs/build/reference/permissive-standards-conformance.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "/permissive- (Standards conformance)"
33
description: "Reference guide to the Microsoft C++ /permissive- (Standards conformance) compiler option."
4-
ms.date: "06/04/2020"
4+
ms.date: 10/28/2020
55
f1_keywords: ["/permissive", "VC.Project.VCCLCompilerTool.ConformanceMode"]
66
helpviewer_keywords: ["/permissive compiler options [C++]", "-permissive compiler options [C++]", "Standards conformance compiler options", "permissive compiler options [C++]"]
77
ms.assetid: db1cc175-6e93-4a2e-9396-c3725d2d8f71
@@ -12,26 +12,29 @@ Specify standards conformance mode to the compiler. Use this option to help you
1212

1313
## Syntax
1414

15-
> **`/permissive-`**
15+
> **`/permissive-`**\
16+
> **`/permissive`**
1617
1718
## Remarks
1819

19-
This option is supported in Visual Studio 2017 and later.
20+
The **`/permissive-`** option is supported in Visual Studio 2017 and later. **`/permissive`** is supported in Visual Studio 2019 version 16.8 and later.
2021

21-
You can use the **`/permissive-`** compiler option to specify standards-conforming compiler behavior. This option disables permissive behaviors, and sets the [**`/Zc`**](zc-conformance.md) compiler options for strict conformance. In the IDE, this option also makes the IntelliSense engine underline non-conforming code.
22+
You can use the **`/permissive-`** compiler option to specify standards-conforming compiler behavior. This option disables permissive behaviors, and sets the [`/Zc`](zc-conformance.md) compiler options for strict conformance. In the IDE, this option also makes the IntelliSense engine underline non-conforming code.
23+
24+
The **`/permissive-`** option uses the conformance support in the current compiler version to determine which language constructs are non-conforming. The option doesn't determine if your code conforms to a specific version of the C++ standard. To enable all implemented compiler support for the latest draft standard, use the [`/std:c++latest`](std-specify-language-standard-version.md) option. To restrict the compiler support to the currently implemented C++17 standard, use the [`/std:c++17`](std-specify-language-standard-version.md) option. To restrict the compiler support to more closely match the C++14 standard, use the [`/std:c++14`](std-specify-language-standard-version.md) option, which is the default.
25+
26+
Starting in Visual Studio 2019 version 16.8, the **`/std:c++latest`** option implicitly sets the **`/permissive-`** option. It's required for C++20 Modules support. Perhaps your code doesn't need modules support but requires other features enabled under **`/std:c++latest`**. You can explicitly enable Microsoft extension support by using the **`/permissive`** option without the trailing dash.
2227

2328
By default, the **`/permissive-`** option is set in new projects created by Visual Studio 2017 version 15.5 and later versions. It's not set by default in earlier versions. When the option is set, the compiler generates diagnostic errors or warnings when non-standard language constructs are detected in your code. These constructs include some common bugs in pre-C++11 code.
2429

2530
The **`/permissive-`** option is compatible with almost all of the header files from the latest Windows Kits, such as the Software Development Kit (SDK) or Windows Driver Kit (WDK), starting in the Windows Fall Creators SDK (10.0.16299.0). Older versions of the SDK may fail to compile under **`/permissive-`** for various source code conformance reasons. The compiler and SDKs ship on different release timelines, so there are some remaining issues. For specific header file issues, see [Windows header issues](#windows-header-issues) below.
2631

27-
The **`/permissive-`** option sets the [**`/Zc:referenceBinding`**](zc-referencebinding-enforce-reference-binding-rules.md), [**`/Zc:strictStrings`**](zc-strictstrings-disable-string-literal-type-conversion.md), and [**`/Zc:rvalueCast`**](zc-rvaluecast-enforce-type-conversion-rules.md) options to conforming behavior. These options defaults to non-conforming behavior. You can pass specific **`/Zc`** options after **`/permissive-`** on the command line to override this behavior.
32+
The **`/permissive-`** option sets the [`/Zc:referenceBinding`](zc-referencebinding-enforce-reference-binding-rules.md), [`/Zc:strictStrings`](zc-strictstrings-disable-string-literal-type-conversion.md), and [`/Zc:rvalueCast`](zc-rvaluecast-enforce-type-conversion-rules.md) options to conforming behavior. These options defaults to non-conforming behavior. You can pass specific **`/Zc`** options after **`/permissive-`** on the command line to override this behavior.
2833

29-
In versions of the compiler beginning in Visual Studio 2017 version 15.3, the **`/permissive-`** option sets the [**`/Zc:ternary`**](zc-ternary.md) option. The compiler also implements more of the requirements for two-phase name look-up. When the **`/permissive-`** option is set, the compiler parses function and class template definitions, and identifies dependent and non-dependent names used in the templates. In this release, only name dependency analysis is performed.
34+
In versions of the compiler beginning in Visual Studio 2017 version 15.3, the **`/permissive-`** option sets the [`/Zc:ternary`](zc-ternary.md) option. The compiler also implements more of the requirements for two-phase name look-up. When the **`/permissive-`** option is set, the compiler parses function and class template definitions, and identifies dependent and non-dependent names used in the templates. In this release, only name dependency analysis is performed.
3035

3136
Environment-specific extensions and language areas that the standard leaves up to the implementation are not affected by **`/permissive-`**. For example, the Microsoft-specific **`__declspec`**, calling convention and structured exception handling keywords, and compiler-specific pragma directives or attributes are not flagged by the compiler in **`/permissive-`** mode.
3237

33-
The **`/permissive-`** option uses the conformance support in the current compiler version to determine which language constructs are non-conforming. The option doesn't determine if your code conforms to a specific version of the C++ standard. To enable all implemented compiler support for the latest draft standard, use the [**`/std:c++latest`**](std-specify-language-standard-version.md) option. To restrict the compiler support to the currently implemented C++17 standard, use the [**`/std:c++17`**](std-specify-language-standard-version.md) option. To restrict the compiler support to more closely match the C++14 standard, use the [**`/std:c++14`**](std-specify-language-standard-version.md) option, which is the default.
34-
3538
Not all C++11, C++14, or C++17 standards-conforming code is supported by the MSVC compiler in all versions of Visual Studio 2017. Depending on the version of Visual Studio, the **`/permissive-`** option may not detect issues in some aspects of two-phase name lookup, binding a non-const reference to a temporary, treating copy init as direct init, allowing multiple user-defined conversions in initialization, or alternative tokens for logical operators, and other non-supported conformance areas. For more information about conformance issues in Visual C++, see [Nonstandard Behavior](../../cpp/nonstandard-behavior.md). To get the most out of **`/permissive-`**, update Visual Studio to the latest version.
3639

3740
### How to fix your code
@@ -414,7 +417,7 @@ These issues are specific to User Mode headers in the Windows Fall Creators Upda
414417
typedef enum UICCDATASTOREACCESSMODE UICCDATASTOREACCESSMODE; // C4471
415418
```
416419

417-
The forward declaration of unscoped enum is a Microsoft extension. To address this issue, compile files that include cellularapi_oem.h without the **`/permissive-`** option, or use the [**`/wd`**](compiler-option-warning-level.md) option to silence warning C4471.
420+
The forward declaration of unscoped enum is a Microsoft extension. To address this issue, compile files that include cellularapi_oem.h without the **`/permissive-`** option, or use the [`/wd`](compiler-option-warning-level.md) option to silence warning C4471.
418421

419422
- Issue in um/omscript.h
420423

docs/overview/cpp-conformance-improvements.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,33 @@ void f() {
11501150
}
11511151
```
11521152

1153+
<!-- TODO 16.8 -->
1154+
## <a name="improvements_168"></a> Conformance improvements in Visual Studio 2019 version 16.8
1155+
1156+
### `/permissive-` and C++20 Modules are on by default under `/std:c++latest`
1157+
1158+
C++20 Modules is now supported, by default, under **`/std:c++latest`**. For more details regarding this change and scenarios where module and import are conditionally treated as keywords, see [Standard C++20 Modules support with MSVC in Visual Studio 2019 version 16.8](https://devblogs.microsoft.com/cppblog/standard-c20-modules-support-with-msvc-in-visual-studio-2019-version-16-8/).
1159+
1160+
As a prerequisite for Modules support, **`/permissive-`** is now enabled when **`/std:c++latest`** is specified. For more information, see [`/permissive-`](../build/reference/permissive-standards-conformance.md).
1161+
For code that previously compiled under **`/std:c++latest`** and requires non-conformant compiler behaviors, /permissive may be specified to turn off strict conformance mode in the compiler and must appear after **`/std:c++latest`** in the command line argument list. However, specifying /permissive will result in an error if Modules usage is encountered.
1162+
1163+
error C1214: Modules conflict with non-standard behavior requested via '[option]'
1164+
Where the most common values for [option] are:
1165+
1166+
Option Description
1167+
/Zc:twoPhase- Two Phase name lookup (/Zc:twoPhase) is required for C++20 Modules and implied by /permissive-. See also /Zc:twoPhase documentation .
1168+
/Zc:hiddenFriend- Enables standard hidden friend name lookup rules is required for C++20 Modules and implied by /permissive-.
1169+
/Zc:preprocessor- Use of the conformant preprocessor (/Zc:preprocessor) is required for C++20 header unit usage and creation only. Named Modules do not require this option. See also /Zc:preprocessor documentation
1170+
When using the std.* Modules which ship with Visual Studio the option /experimental:module is still required for their use as they are not yet standardized.
1171+
1172+
Using /experimental:module also implies /Zc:twoPhase and /Zc:hiddenFriend. Previously code compiled with Modules could sometimes be compiled with /Zc:twoPhase- if the Module was only consumed, this behavior is no longer supported.
1173+
### 'Class rvalue used as lvalue' extension
1174+
### 'Class rvalue used as lvalue' extension
1175+
### 'Class rvalue used as lvalue' extension
1176+
### 'Class rvalue used as lvalue' extension
1177+
### 'Class rvalue used as lvalue' extension
1178+
### 'Class rvalue used as lvalue' extension
1179+
11531180
## <a name="update_160"></a> Bug fixes and behavior changes in Visual Studio 2019
11541181

11551182
### `reinterpret_cast` in a `constexpr` function

0 commit comments

Comments
 (0)