Skip to content

Commit 0967423

Browse files
Merge pull request MicrosoftDocs#4726 from TylerMSFT/conformance
clarify versions that a change applies to
2 parents 5716408 + 2b26d13 commit 0967423

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

docs/overview/cpp-conformance-improvements-2019.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,16 @@ To avoid the errors, insert a space in the offending line before the final angle
6666

6767
### References to types with mismatched cv-qualifiers
6868

69-
Previously, MSVC allowed direct binding of a reference from a type with mismatched cv-qualifiers below the top level. This binding could allow modification of supposedly const data referred to by the reference. The compiler now creates a temporary, as required by the standard. In Visual Studio 2017, the following code compiles without warnings. In Visual Studio 2019, the compiler raises warning C4172:
69+
>[!Note]
70+
> This change only affects Visual Studio 2019 versions 16.0 through 16.8. It was reverted starting in Visual Studio 2019 version 16.9
71+
72+
Previously, MSVC allowed direct binding of a reference from a type with mismatched cv-qualifiers below the top level. This binding could allow modification of supposedly const data referred to by the reference.
73+
74+
The compiler for Visual Studio 2019 versions 16.0 through 16.8 instead creates a temporary, as was required by the standard at that time. Later, the standard retroactively changed making the previous behavior of Visual Studio 2017 and earlier correct, and the behavior of Visual Studio 2019 version 16.0 through 16.8 wrong. Consequently, this change was reverted starting in Visual Studio 2019 version 16.9.
75+
76+
See [Similar types and reference binding](#similar-types-and-reference-binding) for a related change.
77+
78+
As an example, in Visual Studio 2017, the following code compiles without warnings. In Visual Studio 2019 versions 16.0 through 16.8, the compiler raises warning C4172. Starting with Visual Studio 2019 version 16.9, the code once again compiles without warnings:
7079

7180
```cpp
7281
struct X
@@ -2067,10 +2076,14 @@ With this change, a destructor is also potentially throwing if it has a virtual
20672076

20682077
### Similar types and reference binding
20692078

2070-
Core Working Group issue [CWG 2352](https://wg21.link/cwg2352) deals with an inconsistency between the reference binding rules and changes to type similarity. The inconsistency was introduced in earlier Defect Reports (such as [CWG 330](https://wg21.link/cwg330)). With this change, code that previously bound a reference to a temporary may now bind directly when the types involved differ only by cv-qualifiers.
2079+
Core Working Group issue [CWG 2352](https://wg21.link/cwg2352) deals with an inconsistency between the reference binding rules and changes to type similarity. The inconsistency was introduced in earlier Defect Reports (such as [CWG 330](https://wg21.link/cwg330)). This affected Visual Studio 2019 versions 16.0 through 16.8.
2080+
2081+
With this change, starting in Visual Studio 2019 version 16.9, code that previously bound a reference to a temporary in Visual Studio 2019 version 16.0 throught 16.8 may now bind directly when the types involved differ only by cv-qualifiers.
20712082

20722083
Visual Studio 2019 version 16.9 implements the changed behavior in all **`/std`** compiler modes. It's potentially a source breaking change.
20732084

2085+
See [References to types with mismatched cv-qualifiers](#references-to-types-with-mismatched-cv-qualifiers) for a related change.
2086+
20742087
This sample shows the changed behavior:
20752088

20762089
```cpp

0 commit comments

Comments
 (0)