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/build/reference/std-specify-language-standard-version.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -103,7 +103,7 @@ The compiler doesn't support most optional features of ISO C11. Several of these
103
103
104
104
-`aligned_alloc` support is missing, because of the Windows heap implementation. The alternative is to use [`_aligned_malloc`](../../c-runtime-library/reference/aligned-malloc.md).
105
105
106
-
-[DR 400](https://wg14.link/n2148#dr_400) support is currently unimplemented for `realloc`, because this change would break the ABI.
106
+
-[Defect report 400](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_400) support is currently unimplemented for `realloc` because this change would break the ABI.
107
107
108
108
- Variable length array (VLA) support isn't planned. VLAs provide attack vectors comparable to [`gets`](../../c-runtime-library/gets-getws.md), which is deprecated and planned for removal.
Copy file name to clipboardExpand all lines: docs/overview/cpp-conformance-improvements.md
+82-8Lines changed: 82 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,88 @@
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: 03/01/2023
4
+
ms.date: 06/19/2023
5
5
ms.technology: "cpp-language"
6
6
---
7
7
# C++ Conformance improvements, behavior changes, and bug fixes in Visual Studio 2022
8
8
9
-
Microsoft C/C++ in Visual Studio (MSVC) makes conformance improvements and bug fixes in every release. This article lists the significant improvements by major release, then by version. To jump directly to the changes for a specific version, use the list below **In this article**.
9
+
Microsoft C/C++ in Visual Studio (MSVC) makes conformance improvements and bug fixes in every release. This article lists the significant improvements by major release, then by version. To jump directly to the changes for a specific version, use **In this article** links, above.
10
10
11
-
This document lists the changes in Visual Studio 2022. For a guide to the changes in Visual Studio 2019, see [C++ conformance improvements in Visual Studio 2019](cpp-conformance-improvements-2019.md). For changes in Visual Studio 2017, see [C++ conformance improvements in Visual Studio 2017](cpp-conformance-improvements-2017.md). For a complete list of previous conformance improvements, see [Visual C++ What's New 2003 through 2015](../porting/visual-cpp-what-s-new-2003-through-2015.md).
11
+
This document lists the changes in Visual Studio 2022:
12
+
13
+
- For a guide to the changes in Visual Studio 2019, see [C++ conformance improvements in Visual Studio 2019](cpp-conformance-improvements-2019.md).
14
+
- For changes in Visual Studio 2017, see [C++ conformance improvements in Visual Studio 2017](cpp-conformance-improvements-2017.md).
15
+
- For a complete list of previous conformance improvements, see [Visual C++ What's New 2003 through 2015](../porting/visual-cpp-what-s-new-2003-through-2015.md).
16
+
17
+
## <aname="improvements_176"></a> Conformance improvements in Visual Studio 2022 version 17.6
18
+
19
+
Visual Studio 2022 version 17.6 contains the following conformance improvements, bug fixes, and behavior changes in the Microsoft C/C++ compiler.
20
+
21
+
### Compound `volatile` assignments no longer deprecated
22
+
23
+
C++20 deprecated applying certain operators to types qualified with `volatile`. For example, when the following code is compiled with `cl /std:c++20 /Wall test.cpp`:
24
+
25
+
```cpp
26
+
voidf(volatile int& expr)
27
+
{
28
+
++expr;
29
+
}
30
+
```
31
+
32
+
The compiler produces `test.cpp(3): warning C5214: applying '++' to an operand with a volatile qualified type is deprecated in C++20`.
33
+
34
+
In C++20, compound assignment operators (operators of the form `@=`) were deprecated. In C++23, compound operators excluded in C++20 are no longer deprecated. For example, in C++23 the following code doesn't produce a warning, whereas it does in C++20:
35
+
36
+
```cpp
37
+
void f(volatile int& e1, int e2)
38
+
{
39
+
e1 += e2;
40
+
}
41
+
```
42
+
43
+
For more information about this change, see [CWG:2654](https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2654)
44
+
45
+
### Rewriting equality in expressions is less of a breaking change (P2468R2)
46
+
47
+
In C++20, [P2468R2](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2468r2.html) changed the compiler to accept code such as:
48
+
49
+
```cpp
50
+
structS
51
+
{
52
+
bool operator==(const S&);
53
+
bool operator!=(const S&);
54
+
};
55
+
bool b = S{} != S{};
56
+
```
57
+
58
+
The compiler accepts this code, which means that the compiler is more strict with code such as:
59
+
60
+
```c++
61
+
structS
62
+
{
63
+
operator bool() const;
64
+
bool operator==(const S&);
65
+
};
66
+
67
+
bool b = S{} == S{};
68
+
```
69
+
70
+
Version 17.5 of the compiler accepts this program. Version 17.6 of the compiler rejects it. To fix it, add `const` to `operator==` to remove the ambiguity. Or, add a corresponding `operator!=` to the definition as shown in the following example:
71
+
72
+
```cpp
73
+
structS
74
+
{
75
+
operator bool() const;
76
+
bool operator==(const S&);
77
+
bool operator!=(const S&);
78
+
};
79
+
80
+
bool b = S{} == S{};
81
+
```
82
+
83
+
Microsoft C/C++ compiler versions 17.5 and 17.6 accept the previous program, and calls `S::operator==` in both versions.
84
+
85
+
The general programming model outlined in P2468R2 is that if there's a corresponding `operator!=` for a type, it typically suppresses the rewrite behavior. Adding a corresponding `operator!=` is the suggested fix for code that previously compiled in C++17. For more information, see [Programming Model](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2468r2.html#programming-model).
12
86
13
87
## <aname="improvements_174"></a> Conformance improvements in Visual Studio 2022 version 17.4
14
88
@@ -58,7 +132,7 @@ enum Changed
58
132
59
133
In versions of Visual Studio before Visual Studio 2022 version 17.4, the C++ compiler didn't correctly model the types of enumerators. It could assume an incorrect type in enumerations without a fixed underlying type before the closing brace of the enumeration. Under [`/Zc:enumTypes`](../build/reference/zc-enumtypes.md), the compiler now correctly implements the standard behavior.
60
134
61
-
The C++ Standard specifies that within an enumeration definition of no fixed underlying type, the types of enumerators are determined by their initializers. Or, for the enumerators with no initializer, by the type of the previous enumerator (accounting for overflow). Previously, such enumerators were always given the deduced type of the enumeration, with a placeholder for the underlying type (typically **`int`**).
135
+
The C++ Standard specifies that within an enumeration definition of no fixed underlying type, initializers determine the types of enumerators. Or, for the enumerators with no initializer, by the type of the previous enumerator (accounting for overflow). Previously, such enumerators were always given the deduced type of the enumeration, with a placeholder for the underlying type (typically **`int`**).
62
136
63
137
When enabled, the **`/Zc:enumTypes`** option is a potential source and binary breaking change. It's off by default, and not enabled by **`/permissive-`**, because the fix may affect binary compatibility. Some enumeration types change size when the conformant fix is enabled. Certain Windows SDK headers include such enumeration definitions.
64
138
@@ -252,9 +326,9 @@ void f()
252
326
253
327
Visual Studio 2022 version 17.1 contains the following conformance improvements, bug fixes, and behavior changes in the Microsoft C/C++ compiler.
254
328
255
-
### Detect ill-formed capture default in non-local lambda-expressions
329
+
### Detect ill-formed capture default in nonlocal lambda-expressions
256
330
257
-
The C++ Standard only allows a lambda expression in block scope to have a capture-default. In Visual Studio 2022 version 17.1 and later, the compiler detects when a capture default isn't allowed in a non-local lambda expression. It emits a new level 4 warning, C5253.
331
+
The C++ Standard only allows a lambda expression in block scope to have a capture-default. In Visual Studio 2022 version 17.1 and later, the compiler detects when a capture default isn't allowed in a nonlocal lambda expression. It emits a new level 4 warning, C5253.
258
332
259
333
This change is a source breaking change. It applies in any mode that uses the new lambda processor: **`/Zc:lambda`**, **`/std:c++20`**, or **`/std:c++latest`**.
260
334
@@ -267,7 +341,7 @@ In Visual Studio 2022 version 17.1 this code now emits an error:
267
341
268
342
auto incr = [=](int value) { return value + 1; };
269
343
270
-
// capture_default.cpp(3,14): error C5253: a non-local lambda cannot have a capture default
344
+
// capture_default.cpp(3,14): error C5253: a nonlocal lambda cannot have a capture default
271
345
// auto incr = [=](int value) { return value + 1; };
272
346
// ^
273
347
```
@@ -301,7 +375,7 @@ int main(void)
301
375
// C4113: 'int (__cdecl *)(char *)' differs in parameter lists from 'int (__cdecl *)(int)'
302
376
```
303
377
304
-
### Error on a non-dependent `static_assert`
378
+
### Error on a nondependent `static_assert`
305
379
306
380
In Visual Studio 2022 version 17.1 and later, if the expression associated with a `static_assert` isn't a dependent expression, the compiler evaluates the expression as soon as it's parsed. If the expression evaluates to `false`, the compiler emits an error. Previously, if the `static_assert` was within the body of a function template (or within the body of a member function of a class template), the compiler wouldn't perform this analysis.
0 commit comments