Skip to content

Commit 081f7c8

Browse files
authored
Merge pull request MicrosoftDocs#4122 from corob-msft/docs/corob/diagnostics-22222
Add C7553, C5240, diagnostics fixes
2 parents c9891f8 + a9ea741 commit 081f7c8

11 files changed

Lines changed: 198 additions & 47 deletions
Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,59 @@
11
---
2-
description: "Learn more about: /Zm (Specify Precompiled Header Memory Allocation Limit)"
3-
title: "/Zm (Specify Precompiled Header Memory Allocation Limit)"
4-
ms.date: "03/08/2019"
5-
f1_keywords: ["/zm"]
2+
description: "Learn more about: /Zm (Specify precompiled header memory allocation limit)"
3+
title: "/Zm (Specify precompiled header memory allocation limit)"
4+
ms.date: 02/22/2022
5+
f1_keywords: ["/Zm"]
66
helpviewer_keywords: ["PCH files, memory allocation limit", "Zm compiler option [C++]", "/Zm compiler option [C++]", "precompiled header files, memory allocation limit", "Specify Precompiled Header Memory Allocation Limit compiler option", "cl.exe compiler, memory allocation limit", ".pch files, memory allocation limit", "memory allocation, Memory Allocation Limit compiler option", "-Zm compiler option [C++]"]
77
ms.assetid: 94c77d5e-6672-46a7-92e0-3f69e277727d
88
---
9-
# /Zm (Specify Precompiled Header Memory Allocation Limit)
9+
# `/Zm` (Specify precompiled header memory allocation limit)
1010

1111
Determines the amount of memory that the compiler allocates to construct precompiled headers.
1212

1313
## Syntax
1414

15-
```
16-
/Zmfactor
17-
```
15+
> **`/Zm`***`factor`*
1816
1917
## Arguments
2018

21-
*factor*<br/>
22-
A scaling factor that determines the amount of memory that the compiler uses to construct precompiled headers.
19+
*`factor`*<br/>
20+
A scaling factor percentage that determines the amount of memory that the compiler uses to construct precompiled headers.
2321

24-
The *factor* argument is a percentage of the default size of a compiler-defined work buffer. The default value of *factor* is 100 (percent), but you can specify larger or smaller amounts.
22+
The *`factor`* argument is a percentage of the default size of a compiler-defined work buffer. The default value of *`factor`* is 100 (percent), but you can specify larger or smaller amounts.
2523

2624
## Remarks
2725

28-
In versions before Visual Studio 2015, the C++ compiler used several discrete heaps, and each had a finite limit. Currently, the compiler dynamically grows the heaps as necessary up to a total heap size limit, and allows the precompiled header to comprise multiple address ranges. Consequently, the **/Zm** compiler option is rarely necessary.
26+
In versions before Visual Studio 2015, the C++ compiler used several discrete heaps, and each had a finite limit. Currently, the compiler dynamically grows the heaps as necessary up to a total heap size limit, and allows the precompiled header to comprise multiple address ranges. Now, the **`/Zm`** compiler option is rarely necessary.
2927

30-
If the compiler runs out of heap space and emits the [C1060](../../error-messages/compiler-errors-1/fatal-error-c1060.md) error message when you use the **/Zm** compiler option, you might have reserved too much memory. Consider removing the **/Zm** option.
28+
If the compiler runs out of heap space and emits the [C1060](../../error-messages/compiler-errors-1/fatal-error-c1060.md) error message when you use the **`/Zm`** compiler option, you might have reserved too much memory. Consider removing the **`/Zm`** option.
3129

32-
If the compiler emits the [C1076](../../error-messages/compiler-errors-1/fatal-error-c1076.md) error message, an accompanying [C3859](../../error-messages/compiler-errors-2/compiler-error-c3859.md) message specifies the *factor* argument to use when you recompile by using the **/Zm** compiler option. This message is only significant when a precompiled header uses `#pragma hdrstop`. In other cases, it is a spurious error caused by Windows virtual memory pressure issues, and the recommendation to use the **/Zm** option should be ignored. Instead, consider reducing the number of parallel processes when using the **/maxcpucount** option to MSBUILD.EXE in conjunction with the **/MP** option to CL.EXE. For more information, see [Precompiled Header (PCH) issues and recommendations](https://devblogs.microsoft.com/cppblog/precompiled-header-pch-issues-and-recommendations/).
30+
If the compiler emits the [C1076](../../error-messages/compiler-errors-1/fatal-error-c1076.md) error message, an accompanying [C3859](../../error-messages/compiler-errors-2/compiler-error-c3859.md) message specifies the *`factor`* argument to use when you recompile by using the **`/Zm`** compiler option. This message is only significant when a precompiled header uses `#pragma hdrstop`. In other cases, it's a spurious error caused by Windows virtual memory pressure issues, and the recommendation to use the **`/Zm`** option should be ignored. Instead, consider reducing the number of parallel processes when using the **`/maxcpucount`** option to MSBUILD.EXE together with the **`/MP`** option to CL.EXE. For more information, see [Precompiled Header (PCH) issues and recommendations](https://devblogs.microsoft.com/cppblog/precompiled-header-pch-issues-and-recommendations/).
3331

34-
The following table shows how the *factor* argument affects the memory allocation limit if you assume the size of the default precompiled header buffer is 75 MB.
32+
The following table shows how the *`factor`* argument affects the memory allocation limit. In the table, we assume the size of the default precompiled header buffer is 75 MB.
3533

36-
|Value of *factor*|Memory allocation limit|
37-
|-----------------------|-----------------------------|
38-
|10|7.5 MB|
39-
|100|75 MB|
40-
|200|150 MB|
41-
|1000|750 MB|
42-
|2000|1500 MB|
34+
| Value of *`factor`* | Memory allocation limit |
35+
|--|--|
36+
| 10 | 7.5 MB |
37+
| 100 | 75 MB |
38+
| 200 | 150 MB |
39+
| 1000 | 750 MB |
40+
| 2000 | 1500 MB |
4341

44-
## Other Ways to Set the Memory Allocation Limit
42+
## Other ways to set the memory allocation limit
4543

46-
### To set the /Zm compiler option in the Visual Studio development environment
44+
### To set the `/Zm` compiler option in the Visual Studio development environment
4745

4846
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).
4947

5048
1. Select the **Configuration Properties** > **C/C++** > **Command Line** property page.
5149

5250
1. Enter the **/Zm** compiler option in the **Additional Options** box.
5351

54-
### To set the /Zm compiler option programmatically
52+
### To set the `/Zm` compiler option programmatically
5553

5654
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.AdditionalOptions%2A>.
5755

5856
## See also
5957

60-
[MSVC Compiler Options](compiler-options.md)<br/>
61-
[MSVC Compiler Command-Line Syntax](compiler-command-line-syntax.md)
58+
[MSVC compiler options](compiler-options.md)<br/>
59+
[MSVC compiler command-line syntax](compiler-command-line-syntax.md)

docs/error-messages/compiler-errors-1/compiler-error-c2338.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn more about: Compiler Error C2338"
33
title: "Compiler Error C2338"
4-
ms.date: "11/04/2016"
4+
ms.date: 02/22/2022
55
f1_keywords: ["C2338"]
66
helpviewer_keywords: ["C2338"]
77
ms.assetid: 49bba575-1de4-4963-86c6-ce3226a2ba51
@@ -10,9 +10,9 @@ ms.assetid: 49bba575-1de4-4963-86c6-ce3226a2ba51
1010

1111
> *Error message*
1212
13-
This error can be caused by a **`static_assert`** error during compilation. The message is supplied by the **`static_assert`** parameters.
13+
Error C2338 can be caused by a **`static_assert`** error during compilation. The message is supplied by the **`static_assert`** parameters.
1414

15-
This error message can also be generated by external providers to the compiler. In most cases, these errors are reported by an attribute provider DLL, such as ATLPROV. Some common forms of this message include:
15+
Error C2338 can also be generated by external providers to the compiler. In most cases, these errors are reported by an attribute provider DLL, such as ATLPROV. Some common forms of this message include:
1616

1717
- '*attribute*' Atl Attribute Provider : error ATL*number* *message*
1818

@@ -23,3 +23,27 @@ This error message can also be generated by external providers to the compiler.
2323
These errors are often unrecoverable, and may be followed by a fatal compiler error.
2424

2525
To fix these issues, correct the attribute usage. For example, in some cases, attribute parameters must be declared before they can be used. If an ATL error number is provided, check the documentation for that error for more specific information.
26+
27+
In Standard C++11 and later, **`constexpr`** functions are no longer considered **`noexcept`** by default when used in a constant expression. This behavior change comes from the resolution of Core Working Group (CWG) [CWG 1351](https://wg21.link/cwg1351) and is enabled in [`/permissive-`](../../build/reference/permissive-standards-conformance.md) mode. The following example compiles in Visual Studio 2019 version 16.1 and earlier, but produces C2338 in Visual Studio 2019 version 16.2:
28+
29+
```cpp
30+
// c2338.cpp
31+
// Compile using: cl /EHsc /W4 /permissive- c2338.cpp
32+
constexpr int f() { return 0; }
33+
34+
int main() {
35+
static_assert(noexcept(f()), "f should be noexcept"); // C2338 in 16.2
36+
}
37+
```
38+
39+
To fix the error, add the **`noexcept`** expression to the function declaration:
40+
41+
```cpp
42+
// c2338_fixed.cpp
43+
// Compile using: cl /EHsc /W4 /permissive- c2338_fixed.cpp
44+
constexpr int f() noexcept { return 0; }
45+
46+
int main() {
47+
static_assert(noexcept(f()), "f should be noexcept");
48+
}
49+
```
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn more about: Compiler Error C3859"
33
title: "Compiler Error C3859"
4-
ms.date: "03/08/2019"
4+
ms.date: 02/22/2022
55
f1_keywords: ["C3859"]
66
helpviewer_keywords: ["C3859"]
77
ms.assetid: 40e93b25-4393-4467-90de-035434a665c7
@@ -10,6 +10,6 @@ ms.assetid: 40e93b25-4393-4467-90de-035434a665c7
1010

1111
> virtual memory range for PCH exceeded; please recompile with a command line option of '-Zm*value*' or greater
1212
13-
The virtual memory allocated for your precompiled header is too small for the amount of data the compiler is trying to put in it. Starting in Visual Studio 2015, the **/Zm** recommendation is only significant when using the `#pragma hdrstop` directive. In other cases, it's a spurious error that indicates Windows virtual memory pressure issues.
13+
The virtual memory allocated for your precompiled header is too small for the amount of data the compiler is trying to put in it. Starting in Visual Studio 2015, the **`/Zm`** recommendation is only significant when using the `#pragma hdrstop` directive. In other cases, it's a spurious error that indicates Windows virtual memory pressure issues.
1414

15-
If your precompiled header uses a `#pragma hdrstop` directive, use the **/Zm** compiler flag to specify a larger value for the precompiled header file. Otherwise, consider reducing the number of parallel compilation processes in your build. For more information, see [/Zm (Specify Precompiled Header Memory Allocation Limit)](../../build/reference/zm-specify-precompiled-header-memory-allocation-limit.md).
15+
If your precompiled header uses a `#pragma hdrstop` directive, use the **`/Zm`** compiler flag to specify a larger value for the precompiled header file. Otherwise, consider reducing the number of parallel compilation processes in your build. For more information, see [`/Zm` (Specify precompiled header memory allocation limit)](../../build/reference/zm-specify-precompiled-header-memory-allocation-limit.md).
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
title: "Compiler Error C7553"
3+
description: Compiler Error C7553 description and solution.
4+
ms.date: 02/22/2022
5+
f1_keywords: ["C7553"]
6+
helpviewer_keywords: ["C7553"]
7+
---
8+
# Compiler Error C7553
9+
10+
> inline assembler is not supported in a lambda
11+
12+
## Remarks
13+
14+
In versions of Visual Studio before Visual Studio 2017 version 15.9, the use of inline-assembler within a lambda could lead to the corruption of `ebp` (the return address register) at runtime. A malicious attacker could possibly take advantage of this scenario. The inline assembler is only supported on x86, and interaction between the inline assembler and the rest of the compiler is poor. Given these facts and the nature of the issue, the safest solution to this problem was to disallow inline assembler within a lambda expression.
15+
16+
The only use of inline assembler within a lambda expression that we have found 'in the wild' was to capture the return address. In this scenario, you can capture the return address on all platforms simply by using a compiler intrinsic `_ReturnAddress()`.
17+
18+
Compiler Error C7553 occurs in Visual Studio starting in Visual Studio 2017 version 15.9.
19+
20+
## Example
21+
22+
The following code produces C7553 in Visual Studio 2017 15.9 and later versions:
23+
24+
```cpp
25+
#include <cstdio>
26+
27+
int f()
28+
{
29+
int y = 1724;
30+
int x = 0xdeadbeef;
31+
32+
auto lambda = [&]
33+
{
34+
__asm { // C7553: inline assembler is not supported in a lambda
35+
36+
mov eax, x
37+
mov y, eax
38+
}
39+
};
40+
41+
lambda();
42+
return y;
43+
}
44+
```
45+
46+
To avoid the error, move the assembly code into a named function as shown in the following example:
47+
48+
```cpp
49+
#include <cstdio>
50+
51+
void g(int& x, int& y)
52+
{
53+
__asm {
54+
mov eax, x
55+
mov y, eax
56+
}
57+
}
58+
59+
int f()
60+
{
61+
int y = 1724;
62+
int x = 0xdeadbeef;
63+
auto lambda = [&]
64+
{
65+
g(x, y);
66+
};
67+
lambda();
68+
return y;
69+
}
70+
71+
int main()
72+
{
73+
std::printf("%d\n", f());
74+
}
75+
```

docs/error-messages/compiler-errors-2/compiler-errors-c7500-through-c7999.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
description: "Learn more about: Compiler errors C7500 through C7999"
33
title: "Compiler errors C7500 through C7999"
44
ms.date: 04/18/2021
5-
f1_keywords: ["C7500", "C7501", "C7502", "C7503", "C7504", "C7505", "C7506", "C7507", "C7508", "C7509", "C7511", "C7512", "C7513", "C7514", "C7515", "C7516", "C7517", "C7518", "C7519", "C7520", "C7521", "C7522", "C7523", "C7524", "C7525", "C7526", "C7527", "C7528", "C7529", "C7530", "C7531", "C7532", "C7533", "C7534", "C7535", "C7537", "C7538", "C7539", "C7540", "C7541", "C7542", "C7543", "C7544", "C7545", "C7546", "C7547", "C7548", "C7549", "C7550", "C7551", "C7552", "C7553", "C7554", "C7555", "C7556", "C7557", "C7558", "C7559", "C7560", "C7561", "C7562", "C7563", "C7564", "C7565", "C7566", "C7567", "C7568", "C7569", "C7570", "C7571", "C7572", "C7573", "C7574", "C7575", "C7576", "C7577", "C7578", "C7579", "C7580", "C7581", "C7582", "C7583", "C7584", "C7585", "C7586", "C7587", "C7588", "C7589", "C7590", "C7591", "C7592", "C7593", "C7594", "C7595", "C7596", "C7597", "C7599", "C7600", "C7601", "C7602", "C7603", "C7604", "C7605", "C7606", "C7607", "C7608", "C7609", "C7610", "C7611", "C7612", "C7613", "C7614", "C7615", "C7616", "C7617", "C7618", "C7619", "C7620", "C7621", "C7622", "C7623", "C7624", "C7625", "C7627", "C7628", "C7629", "C7630", "C7631", "C7632", "C7633", "C7634", "C7635", "C7636", "C7637", "C7638", "C7639", "C7640", "C7641", "C7642", "C7643", "C7644", "C7645", "C7646", "C7647", "C7648", "C7649", "C7650", "C7651", "C7652", "C7653", "C7654", "C7655", "C7656", "C7657", "C7658", "C7659", "C7660", "C7661", "C7662", "C7700", "C7701", "C7702", "C7703", "C7704"]
6-
helpviewer_keywords: ["C7500", "C7501", "C7502", "C7503", "C7504", "C7505", "C7506", "C7507", "C7508", "C7509", "C7511", "C7512", "C7513", "C7514", "C7515", "C7516", "C7517", "C7518", "C7519", "C7520", "C7521", "C7522", "C7523", "C7524", "C7525", "C7526", "C7527", "C7528", "C7529", "C7530", "C7531", "C7532", "C7533", "C7534", "C7535", "C7537", "C7538", "C7539", "C7540", "C7541", "C7542", "C7543", "C7544", "C7545", "C7546", "C7547", "C7548", "C7549", "C7550", "C7551", "C7552", "C7553", "C7554", "C7555", "C7556", "C7557", "C7558", "C7559", "C7560", "C7561", "C7562", "C7563", "C7564", "C7565", "C7566", "C7567", "C7568", "C7569", "C7570", "C7571", "C7572", "C7573", "C7574", "C7575", "C7576", "C7577", "C7578", "C7579", "C7580", "C7581", "C7582", "C7583", "C7584", "C7585", "C7586", "C7587", "C7588", "C7589", "C7590", "C7591", "C7592", "C7593", "C7594", "C7595", "C7596", "C7597", "C7599", "C7600", "C7601", "C7602", "C7603", "C7604", "C7605", "C7606", "C7607", "C7608", "C7609", "C7610", "C7611", "C7612", "C7613", "C7614", "C7615", "C7616", "C7617", "C7618", "C7619", "C7620", "C7621", "C7622", "C7623", "C7624", "C7625", "C7627", "C7628", "C7629", "C7630", "C7631", "C7632", "C7633", "C7634", "C7635", "C7636", "C7637", "C7638", "C7639", "C7640", "C7641", "C7642", "C7643", "C7644", "C7645", "C7646", "C7647", "C7648", "C7649", "C7650", "C7651", "C7652", "C7653", "C7654", "C7655", "C7656", "C7657", "C7658", "C7659", "C7660", "C7661", "C7662", "C7700", "C7701", "C7702", "C7703", "C7704"]
5+
f1_keywords: ["C7500", "C7501", "C7502", "C7503", "C7504", "C7505", "C7506", "C7507", "C7508", "C7509", "C7511", "C7512", "C7513", "C7514", "C7515", "C7516", "C7517", "C7518", "C7519", "C7520", "C7521", "C7522", "C7523", "C7524", "C7525", "C7526", "C7527", "C7528", "C7529", "C7530", "C7531", "C7532", "C7533", "C7534", "C7535", "C7537", "C7538", "C7539", "C7540", "C7541", "C7542", "C7543", "C7544", "C7545", "C7546", "C7547", "C7548", "C7549", "C7550", "C7551", "C7552", "C7554", "C7555", "C7556", "C7557", "C7558", "C7559", "C7560", "C7561", "C7562", "C7563", "C7564", "C7565", "C7566", "C7567", "C7568", "C7569", "C7570", "C7571", "C7572", "C7573", "C7574", "C7575", "C7576", "C7577", "C7578", "C7579", "C7580", "C7581", "C7582", "C7583", "C7584", "C7585", "C7586", "C7587", "C7588", "C7589", "C7590", "C7591", "C7592", "C7593", "C7594", "C7595", "C7596", "C7597", "C7599", "C7600", "C7601", "C7602", "C7603", "C7604", "C7605", "C7606", "C7607", "C7608", "C7609", "C7610", "C7611", "C7612", "C7613", "C7614", "C7615", "C7616", "C7617", "C7618", "C7619", "C7620", "C7621", "C7622", "C7623", "C7624", "C7625", "C7627", "C7628", "C7629", "C7630", "C7631", "C7632", "C7633", "C7634", "C7635", "C7636", "C7637", "C7638", "C7639", "C7640", "C7641", "C7642", "C7643", "C7644", "C7645", "C7646", "C7647", "C7648", "C7649", "C7650", "C7651", "C7652", "C7653", "C7654", "C7655", "C7656", "C7657", "C7658", "C7659", "C7660", "C7661", "C7662", "C7700", "C7701", "C7702", "C7703", "C7704"]
6+
helpviewer_keywords: ["C7500", "C7501", "C7502", "C7503", "C7504", "C7505", "C7506", "C7507", "C7508", "C7509", "C7511", "C7512", "C7513", "C7514", "C7515", "C7516", "C7517", "C7518", "C7519", "C7520", "C7521", "C7522", "C7523", "C7524", "C7525", "C7526", "C7527", "C7528", "C7529", "C7530", "C7531", "C7532", "C7533", "C7534", "C7535", "C7537", "C7538", "C7539", "C7540", "C7541", "C7542", "C7543", "C7544", "C7545", "C7546", "C7547", "C7548", "C7549", "C7550", "C7551", "C7552", "C7554", "C7555", "C7556", "C7557", "C7558", "C7559", "C7560", "C7561", "C7562", "C7563", "C7564", "C7565", "C7566", "C7567", "C7568", "C7569", "C7570", "C7571", "C7572", "C7573", "C7574", "C7575", "C7576", "C7577", "C7578", "C7579", "C7580", "C7581", "C7582", "C7583", "C7584", "C7585", "C7586", "C7587", "C7588", "C7589", "C7590", "C7591", "C7592", "C7593", "C7594", "C7595", "C7596", "C7597", "C7599", "C7600", "C7601", "C7602", "C7603", "C7604", "C7605", "C7606", "C7607", "C7608", "C7609", "C7610", "C7611", "C7612", "C7613", "C7614", "C7615", "C7616", "C7617", "C7618", "C7619", "C7620", "C7621", "C7622", "C7623", "C7624", "C7625", "C7627", "C7628", "C7629", "C7630", "C7631", "C7632", "C7633", "C7634", "C7635", "C7636", "C7637", "C7638", "C7639", "C7640", "C7641", "C7642", "C7643", "C7644", "C7645", "C7646", "C7647", "C7648", "C7649", "C7650", "C7651", "C7652", "C7653", "C7654", "C7655", "C7656", "C7657", "C7658", "C7659", "C7660", "C7661", "C7662", "C7700", "C7701", "C7702", "C7703", "C7704"]
77
---
88
# Compiler errors C7500 through C7999
99

@@ -68,7 +68,7 @@ The articles in this section of the documentation explain a subset of the error
6868
| Compiler error C7550 | '%1$S': the qualified name in this context names a constructor, not a type |
6969
| Compiler error C7551 | '%1$pS': template parameter '%2$S': '%3$pS': purely intrinsic functions have no address for use as a non-type template argument |
7070
| Compiler error C7552 | '%1$S': purely intrinsic functions have no address |
71-
| Compiler error C7553 | inline assembler is not supported in a lambda |
71+
| [Compiler error C7553](compiler-error-c7553.md) | inline assembler is not supported in a lambda |
7272
| Compiler error C7554 | %1$pS is not an integral constant expression |
7373
| Compiler error C7555 | use of designated initializers requires at least '%1$M' |
7474
| Compiler error C7556 | cannot mix designated-initializers with non-designated-initializers |

0 commit comments

Comments
 (0)