You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/overview/cpp-conformance-improvements.md
+69-5Lines changed: 69 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "C++ conformance improvements in Visual Studio 2022"
3
3
description: "Microsoft C++ in Visual Studio is improving standards conformance and fixing bugs regularly."
4
-
ms.date: 2/11/2025
4
+
ms.date: 05/13/2025
5
5
ms.service: "visual-cpp"
6
6
ms.subservice: "cpp-lang"
7
7
---
@@ -19,15 +19,79 @@ For changes in earlier versions of Visual Studio:
19
19
| 2017 |[C++ conformance improvements in Visual Studio 2017](cpp-conformance-improvements-2017.md)|
20
20
| 2003-2015 |[Visual C++ What's New 2003 through 2015](../porting/visual-cpp-what-s-new-2003-through-2015.md)|
21
21
22
+
## <aname="improvements_1714"></a> Conformance improvements in Visual Studio 2022 version 17.14
23
+
24
+
Visual Studio 2022 version 17.14 includes the following conformance improvements, bug fixes, and behavior changes in the Microsoft C/C++ compiler.
25
+
26
+
### Conformance improvements
27
+
28
+
- Standard library hardening ([P3471R4](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3471r4.html)) turns some instances of undefined behavior in the standard library into a call to [__fastfail](../intrinsics/fastfail.md). Off by default. Define `_MSVC_STL_HARDENING=1` project-wide to enable.
29
+
30
+
### Enhanced behavior
31
+
32
+
- Implemented "destructor tombstones" to mitigate use-after-free mistakes. Off by default. Define `_MSVC_STL_DESTRUCTOR_TOMBSTONES=1` project-wide to enable.
33
+
34
+
### Bug fixes
35
+
36
+
- Fixed errant compiler errors when using `<format>` in a CUDA project.
37
+
- Fixed a compiler issue where the address of a local variable could "leak" during `constexpr` evaluation. For example:
38
+
39
+
```cpp
40
+
constunsigned & func()
41
+
{
42
+
const int x = 0;
43
+
constexpr const unsigned & r1 = x; // Previously accepted, now an error
44
+
return r1;
45
+
}
46
+
47
+
auto r = func(); // Previously, the local address leaked
48
+
```
49
+
50
+
**Example #2**
51
+
52
+
```cpp
53
+
#include <initializer_list>
54
+
55
+
void test()
56
+
{
57
+
constexpr std::initializer_list<int> xs { 1, 2, 3 }; // Previously accepted, now an error
58
+
59
+
static constexpr std::initializer_list<int> ys { 1, 2, 3 }; // Correct usage - note use of static
60
+
}
61
+
```
62
+
63
+
- Code compiled with `/permissive-` no longer accepts a combination of `friend` and `static` on a declaration. The fix is usually to remove `static` from the declaration. For example:
64
+
65
+
```cpp
66
+
structS
67
+
{
68
+
friend static void f(); // Previously accepted, now emits error C2440: 'static' cannot be used with 'friend'
69
+
};
70
+
```
71
+
72
+
- Reference binding to volatile-qualified types fixed when referring to a base or derived class. For example:
73
+
74
+
```cpp
75
+
struct A {};
76
+
struct B : public A {};
77
+
78
+
void f(A&); // 1
79
+
void f(const volatile A&); // 2
80
+
81
+
f(B{}); // Previously called 2. This is ill-formed under /permissive- or /Zc:referenceBinding. Chooses 1 if relaxed reference binding rules are enabled.
82
+
```
83
+
84
+
For an in-depth summary of changes made to the Standard Template Library, including conformance changes, bug fixes, and performance improvements, see [STL Changelog VS 2022 17.14](https://github.com/microsoft/STL/wiki/Changelog#vs-2022-1714).
85
+
22
86
## <aname="improvements_1713"></a> Conformance improvements in Visual Studio 2022 version 17.13
23
87
24
88
Visual Studio 2022 version 17.13 includes the following conformance improvements, bug fixes, and behavior changes in the Microsoft C/C++ compiler.
25
89
26
90
For an in-depth summary of changes made to the Standard Template Library, including conformance changes, bug fixes, and performance improvements, see [STL Changelog VS 2022 17.13](https://github.com/microsoft/STL/wiki/Changelog#vs-2022-1713).
27
91
28
-
### Argument-dependent lookup (ADL) change
92
+
### Argument-dependent lookup (ADL)
29
93
30
-
Language constructs such as range-for and structured bindings have special argument-dependent lookup rules for certain identifiers such as `begin`, `end`, or `get`. Previously, this lookup included candidates from the `std` namespace, even when namespace `std`is not part of the ordinary set of associated namespaces for argument-dependent lookup.
94
+
Language constructs such as range-for and structured bindings have special argument-dependent lookup rules for certain identifiers such as `begin`, `end`, or `get`. Previously, this lookup included candidates from the `std` namespace, even when namespace `std`isn't part of the ordinary set of associated namespaces for argument-dependent lookup.
31
95
32
96
Programs that introduced declarations to `std` for these constructs no longer compile. Instead, the declarations should be in a normal associated namespace for the types involved (possibly including the global namespace).
33
97
@@ -73,9 +137,9 @@ For an in-depth summary of changes made to the Standard Template Library, includ
73
137
74
138
This is a source/binary breaking change.
75
139
76
-
The implicit conversion to `bool` from `_com_ptr_t` instances can be surprising or lead to compiler errors. Implicit conversion functions are discouraged by the [C++ Core Guidelines (C.164)](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Ro-conversion), and`_com_ptr_t` contained implicit conversions to both `bool` and `Interface*`. These two implicit conversions can lead to ambiguities.
140
+
The implicit conversion to `bool` from `_com_ptr_t` instances can be surprising or lead to compiler errors. The [C++ Core Guidelines (C.164)](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Ro-conversion) discourage implicit conversion functions. And`_com_ptr_t` contained implicit conversions to both `bool` and `Interface*`. These two implicit conversions can lead to ambiguities.
77
141
78
-
To help address this, the conversion to `bool` is now explicit. The conversion to `Interface*` is unchanged.
142
+
To address this, the conversion to `bool` is now explicit. The conversion to `Interface*` is unchanged.
79
143
80
144
A macro is provided to opt-out of this new behavior and restore the previous implicit conversion. Compile with `/D_COM_DISABLE_EXPLICIT_OPERATOR_BOOL` to opt-out of this change. We recommend that you modify the code to not rely on implicit conversions.
0 commit comments