Skip to content

Repo sync for protected CLA branch #4449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/build-insights/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ metadata:
title: C++ Build Insights
description: Learn how to use C++ Build Insights to analyze and optimize your builds.
ms.topic: landing-page
author: corob-msft
ms.author: corob
author: tylermsft
ms.author: twhitney
ms.date: 05/26/2020
ms.custom: intro-landing-hub

Expand Down
2 changes: 1 addition & 1 deletion docs/build/building-on-the-command-line.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ When used with no arguments, *`vcvarsall.bat`* configures the environment variab

### `vcvarsall` syntax

> **`vcvarsall.bat`** [*`architecture`*] [*`platform_type`*] [*`winsdk_version`*] [**`-vcvars_ver=`**_`vcversion`_] [*`spectre_mode`*]
> **`vcvarsall.bat`** [*`architecture`*] [*`platform_type`*] [*`winsdk_version`*] [**`-vcvars_ver=`***`vcversion`*] [*`spectre_mode`*]

*`architecture`*<br/>
This optional argument specifies the host and target architecture to use. If *architecture* isn't specified, the default build environment is used. These arguments are supported:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ ms.topic: "reference"
f1_keywords: ["VC.Project.VCLinkerTool.CLRUnmanagedCodeCheck", "/CLRUNMANAGEDCODECHECK"]
helpviewer_keywords: ["-CLRUNMANAGEDCODECHECK linker option", "/CLRUNMANAGEDCODECHECK linker option"]
ms.assetid: 73abc426-dab0-45e2-be85-0f9a14206cc2
author: "corob-msft"
ms.author: "corob"
author: "tylermsft"
ms.author: "twhitney"
---
# `/CLRUNMANAGEDCODECHECK` (Remove SuppressUnmanagedCodeSecurityAttribute)

Expand Down
4 changes: 2 additions & 2 deletions docs/build/reference/scandependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
title: "/scanDependencies (List module and header unit dependencies per Standard)"
description: "Reference guide to the /scanDependencies compiler option in Microsoft C++."
ms.date: 09/21/2022
author: "corob-msft"
ms.author: "corob"
author: "tylermsft"
ms.author: "twhitney"
f1_keywords: ["/scanDependencies"]
helpviewer_keywords: ["/scanDependencies compiler option", "/scanDependencies"]
---
Expand Down
4 changes: 2 additions & 2 deletions docs/cross-platform/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ metadata:
title: Mobile development with C++ documentation
description: Create native C++ apps for iOS, Android, and Windows devices with Visual Studio.
ms.topic: landing-page
author: corob-msft
ms.author: corob
author: tylermsft
ms.author: twhitney
ms.date: 05/26/2020
ms.custom: intro-landing-hub

Expand Down
88 changes: 44 additions & 44 deletions docs/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,78 +154,78 @@
"windows/**.md": "cpp-windows"
},
"author": {
"index.md": "corob-msft",
"assembler/**.md": "corob-msft",
"attributes/**.md": "corob-msft",
"index.md": "tylermsft",
"assembler/**.md": "tylermsft",
"attributes/**.md": "tylermsft",
"atl/**.md": "tylermsft",
"atl-mfc-shared/**.md": "tylermsft",
"build/**.md": "corob-msft",
"build/**.md": "tylermsft",
"build-insights/**.md": "kevcadieux",
"c-language/**.md": "corob-msft",
"c-language/**.md": "tylermsft",
"c-runtime-library/**.md": "tylermsft",
"cloud/**.md": "corob-msft",
"code-quality/**.md": "corob-msft",
"cpp/**.md": "corob-msft",
"cppcx/**.md": "corob-msft",
"cross-platform/**.md": "corob-msft",
"data/**.md": "corob-msft",
"cloud/**.md": "tylermsft",
"code-quality/**.md": "tylermsft",
"cpp/**.md": "tylermsft",
"cppcx/**.md": "tylermsft",
"cross-platform/**.md": "tylermsft",
"data/**.md": "tylermsft",
"dotnet/**.md": "tylermsft",
"error-messages/**.md": "corob-msft",
"extensions/**.md": "corob-msft",
"get-started/**.md": "corob-msft",
"ide/**.md": "corob-msft",
"intrinsics/**.md": "corob-msft",
"error-messages/**.md": "tylermsft",
"extensions/**.md": "tylermsft",
"get-started/**.md": "tylermsft",
"ide/**.md": "tylermsft",
"intrinsics/**.md": "tylermsft",
"linux/**.md": "tylermsft",
"mfc/**.md": "tylermsft",
"overview/**.md": "corob-msft",
"overview/**.md": "tylermsft",
"parallel/amp/**.md": "tylermsft",
"parallel/concrt/**.md": "tylermsft",
"parallel/**.md": "tylermsft",
"porting/**.md": "corob-msft",
"preprocessor/**.md": "corob-msft",
"porting/**.md": "tylermsft",
"preprocessor/**.md": "tylermsft",
"safeint/**.md": "tylermsft",
"sanitizers/**.md": "corob-msft",
"security/**.md": "corob-msft",
"sanitizers/**.md": "tylermsft",
"security/**.md": "tylermsft",
"standard-library/**.md": "tylermsft",
"text/**.md": "tylermsft",
"windows/**.md": "corob-msft"
"windows/**.md": "tylermsft"
},
"ms.author": {
"index.md": "corob",
"assembler/**.md": "corob",
"index.md": "twhitney",
"assembler/**.md": "twhitney",
"atl/**.md": "twhitney",
"atl-mfc-shared/**.md": "twhitney",
"attributes/**.md": "corob",
"build/**.md": "corob",
"attributes/**.md": "twhitney",
"build/**.md": "twhitney",
"build-insights/**.md": "kevca",
"c-language/**.md": "corob",
"c-language/**.md": "twhitney",
"c-runtime-library/**.md": "twhitney",
"cloud/**.md": "corob",
"code-quality/**.md": "corob",
"cpp/**.md": "corob",
"cppcx/**.md": "corob",
"cross-platform/**.md": "corob",
"data/**.md": "corob",
"cloud/**.md": "twhitney",
"code-quality/**.md": "twhitney",
"cpp/**.md": "twhitney",
"cppcx/**.md": "twhitney",
"cross-platform/**.md": "twhitney",
"data/**.md": "twhitney",
"dotnet/**.md": "twhitney",
"error-messages/**.md": "corob",
"extensions/**.md": "corob",
"get-started/**.md": "corob",
"ide/**.md": "corob",
"intrinsics/**.md": "corob",
"error-messages/**.md": "twhitney",
"extensions/**.md": "twhitney",
"get-started/**.md": "twhitney",
"ide/**.md": "twhitney",
"intrinsics/**.md": "twhitney",
"linux/**.md": "twhitney",
"mfc/**.md": "twhitney",
"overview/**.md": "corob",
"overview/**.md": "twhitney",
"parallel/amp/**.md": "twhitney",
"parallel/concrt/**.md": "twhitney",
"parallel/**.md": "twhitney",
"porting/**.md": "corob",
"preprocessor/**.md": "corob",
"porting/**.md": "twhitney",
"preprocessor/**.md": "twhitney",
"safeint/**.md": "twhitney",
"sanitizers/**.md": "corob",
"security/**.md": "corob",
"sanitizers/**.md": "twhitney",
"security/**.md": "twhitney",
"standard-library/**.md": "twhitney",
"text/**.md": "twhitney",
"windows/**.md": "corob"
"windows/**.md": "twhitney"
}
},
"template": [],
Expand Down
44 changes: 44 additions & 0 deletions docs/error-messages/compiler-errors-2/compiler-error-c7688.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: "Compiler error C7688"
description: Compiler error C7688 description and solution.
ms.date: 03/01/2023
f1_keywords: ["C7688"]
helpviewer_keywords: ["C7688"]
---
# Compiler error C7688

> '`pragma omp atomic`': expected an expression of scalar type

## Remarks

OpenMP restricts expressions in `#pragma omp atomic` constructs to scalar type.

Compiler error C7688 is new in Visual Studio 2022 version 17.4. In previous compiler versions, the compiler would emit error [C3048](./compiler-error-c3048.md).

## Example

The sample code shows diagnostics generated for non-scalar types in `#pragma omp atomic` constructs.

```cpp
// C7688.cpp
// compile using /c /openmp:llvm
struct S { char c; };
S operator+(S, int);

void test()
{
S s1, s2;
#pragma omp atomic capture
{ s1 = s2; s2 = s1 + 1; }
}
/*
When built, the compiler emits:

.\C7688.cpp(10,10): error C7688: '#pragma omp atomic': expected an expression of scalar type
{ s1 = s2; s2 = s1 + 1; }
^
.\C7688.cpp(10,10): note: type is 'S'
*/
```

To resolve this issue, use scalar types in `#pragma omp atomic` constructs.
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ The articles in this section of the documentation explain a subset of the error
| Compiler error C7660 | '%s': requires '%s' command line option(s) |
| Compiler error C7661 | header-name '%s' has an ambiguous resolution to header '%s' |
| Compiler error C7662 | '%$S': a coroutine cannot be constexpr or consteval |
| [Compiler error C7688](compiler-error-c7688.md) | '`#pragma omp atomic`': expected an expression of scalar type |
| Compiler error C7700 | type '%$T' in _Generic association compatible with previous association type '%$T' |
| Compiler error C7701 | default _Generic association previously specified |
| Compiler error C7702 | no compatible type for '%$T' in _Generic association list |
Expand Down
60 changes: 60 additions & 0 deletions docs/error-messages/compiler-warnings/c5262.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: "Compiler warning (level 1, error, off) C5262"
description: Compiler warning C5262 description and solution.
ms.date: 03/01/2023
f1_keywords: ["C5262"]
helpviewer_keywords: ["C5262"]
---
# Compiler warning (level 1, error, off) C5262

> implicit fall-through occurs here; are you missing a `break` statement? Use `[[fallthrough]]` when a `break` statement is intentionally omitted between cases

## Remarks

Control flow that implicitly falls between cases of switch statements is a historical source of bugs for both C and C++. While we had the `__fallthrough` SAL macro, it wasn't useful for the build-compiler diagnostics. Since customers have legacy code that "falls through" on purpose, it isn't viable to give an actionable warning without some way of indicating an intentional fall through. In C++17, the `[[fallthrough]]` attribute was added to indicate such an instance. The compiler can take this attribute into account and suppress the new warning.

Compiler warning C5262 is new in Visual Studio 2022 version 17.4, and is both off by default and treated as an error by default when enabled. To continue to support legacy code without build breaks, C5262 must be explicitly enabled. For more information on how to enable this warning, see [Compiler warnings that are off by default](../../preprocessor/compiler-warnings-that-are-off-by-default.md).

## Example

The sample code shows diagnostics for `switch` cases that fall through without `break` or `return` statements or the `[[fallthrough]]` attribute.

```cpp
// C5262.cpp
// compile using /std:c++17 /we5262

int main(int argc, char** argv)
{
switch (argc)
{
case 0: ++argv;
case 1:
case 2: argv++;
default:
argv = 0;
}
}

/*
When built, the compiler produces this output:

.\C5262.cpp(9,9): error C5262: implicit fall-through occurs here; are you missing a break statement? Use [[fallthrough]] when a break statement is intentionally omitted between cases
case 1:
^
.\C5262.cpp(8,17): note: statement that may fall through is here
case 0: ++argv;
^
.\C5262.cpp(11,9): error C5262: implicit fall-through occurs here; are you missing a break statement? Use [[fallthrough]] when a break statement is intentionally omitted between cases
default:
^
.\C5262.cpp(10,17): note: statement that may fall through is here
case 2: argv++;
*/
```

To resolve this issue when the control flow between cases is intentional, use the `[[fallthrough]]` attribute.

## See also

[`switch` statement (C++)](../../cpp/switch-statement-cpp.md)\
[`[[fallthrough]]` attribute](../../cpp/attributes.md#fallthrough)
48 changes: 48 additions & 0 deletions docs/error-messages/compiler-warnings/c5301-c5302.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: "Compiler warnings (level 1) C5301 and C5302"
description: Compiler warnings C5301 and C5302 description and solution.
ms.date: 03/01/2023
f1_keywords: ["C5301", "C5302"]
helpviewer_keywords: ["C5301", "C5302"]
---
# Compiler warnings (level 1) C5301 and C5302

> '`#pragma omp for`': '*loop-index*' increases while loop condition uses '*comparison*'; non-terminating loop?

> '`#pragma omp for`': '*loop-index*' decreases while loop condition uses '*comparison*'; non-terminating loop?

## Remarks

Along with improved support for OpenMP 3.1, we've added two diagnostics, C5301 and C5302, to improve the developer experience. These diagnostics check that the loop conditions for `omp parallel for` are correct, based on whether the loop index variable is increasing or decreasing. These checks work for both integral and pointer indices.

These compiler warnings are new in Visual Studio 2022 version 17.4.

## Example

The sample code shows a diagnostic for a `for` loop that decrements the index, but it uses a `<=` comparison that tests whether the index is less than a value higher than the starting value.

```C
// C5302.c
// compile using /openmp

#include <stdio.h>

int main()
{
int a[100], i;
int k = 1;
#pragma omp parallel for
for (i = 0; i <= 100; i--)
a[i] = i*i;
}

/*
Compiler warning message:

.\C5302.c(11,19): warning C5302: '#pragma omp for': 'i' decreases while loop condition uses '<='; non-terminating loop?
for (i = 0; i <= 100; i--)
^
*/
```

To resolve this issue, change the test condition or the direction of the index change to one that terminates without causing overflow, underflow, or other undefined behavior.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Compiler Warnings by compiler version"
description: "Table of Microsoft C/C++ compiler warnings by compiler version."
ms.date: 11/07/2022
ms.date: 02/28/2023
helpviewer_keywords: ["warnings, by compiler version", "cl.exe compiler, setting warning options"]
---
# Compiler Warnings by compiler version
Expand Down Expand Up @@ -47,13 +47,23 @@ These versions of the compiler introduced new warnings:
| Visual Studio 2022 version 17.2 | 19.32 |
| Visual Studio 2022 version 17.3 | 19.33 |
| Visual Studio 2022 version 17.4 | 19.34 |
| Visual Studio 2022 version 17.5 | 19.35 |

You can specify only the major number, the major and minor numbers, or the major, minor, and build numbers to the **`/Wv`** option. The compiler reports all warnings that match versions that begin with the specified number. It suppresses all warnings for versions greater than the specified number. For example, **`/Wv:17`** reports warnings introduced in or before any version of Visual Studio 2012, and suppresses warnings introduced by any compiler from Visual Studio 2013 (version 18) or later. To suppress warnings introduced in Visual Studio 2015 update 2 and later, you can use **`/Wv:19.00.23506`**. Use **`/Wv:19.11`** to report the warnings introduced in any version of Visual Studio before Visual Studio 2017 version 15.5, but suppress warnings introduced in Visual Studio 2017 version 15.5 and later.

The following sections list the warnings introduced by each version of Visual C++ that you can suppress by using the **`/Wv`** compiler option. The **`/Wv`** option can't suppress warnings that aren't listed, which predate the specified versions of the compiler.

::: moniker range=">= msvc-170"

## Warnings introduced in Visual Studio 2022 version 17.5 (compiler version 19.35)

These warnings and all warnings in later versions are suppressed by using the compiler option **`/Wv:19.34`**.

| Warning | Message |
|--|--|
| C5082 | second argument to '`va_start`' is not the last named parameter |
| C5265 | cannot open search path '*pathname*' |

## Warnings introduced in Visual Studio 2022 version 17.4 (compiler version 19.34)

These warnings and all warnings in later versions are suppressed by using the compiler option **`/Wv:19.33`**.
Expand Down
Loading