Skip to content

Repo sync for protected branch #4908

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 11 commits into from
Jan 22, 2024
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
7 changes: 0 additions & 7 deletions docs/cpp/welcome-back-to-cpp-modern-cpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ title: "Welcome back to C++ - Modern C++"
description: "Describes the new programming idioms in Modern C++ and their rationale."
ms.date: 06/02/2022
ms.topic: "conceptual"
ms.assetid: 1cb1b849-ed9c-4721-a972-fd8f3dab42e2
---
# Welcome back to C++ - Modern C++

Expand Down Expand Up @@ -64,10 +63,7 @@ apple_color["Granny Smith"] = "Green";

When performance optimization is needed, consider using:

- The [`array`](../standard-library/array-class-stl.md) type when embedding is important, for example, as a class member.

- Unordered associative containers such as [`unordered_map`](../standard-library/unordered-map-class.md). These have lower per-element overhead and constant-time lookup, but they can be harder to use correctly and efficiently.

- Sorted `vector`. For more information, see [Algorithms](../standard-library/algorithms.md).

Don't use C-style arrays. For older APIs that need direct access to the data, use accessor methods such as `f(vec.data(), vec.size());` instead. For more information about containers, see [C++ Standard Library Containers](../standard-library/stl-containers.md).
Expand All @@ -79,11 +75,8 @@ Before you assume that you need to write a custom algorithm for your program, fi
Here are some important examples:

- `for_each`, the default traversal algorithm (along with range-based `for` loops).

- `transform`, for not-in-place modification of container elements

- `find_if`, the default search algorithm.

- `sort`, `lower_bound`, and the other default sorting and searching algorithms.

To write a comparator, use strict **`<`** and use *named lambdas* when you can.
Expand Down
4 changes: 2 additions & 2 deletions docs/error-messages/compiler-warnings/c4834.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: "Learn about the cause and fixes for Compiler warning (level 1) C4834."
title: "Compiler warning (Level 1) C4834"
ms.date: 07/26/2021
ms.date: 01/18/2024
f1_keywords: ["C4834"]
helpviewer_keywords: ["C4834"]
---
Expand All @@ -11,7 +11,7 @@ helpviewer_keywords: ["C4834"]

## Remarks

Starting in the C++17 Standard, the `[[nodiscard]]` attribute specifies that a function's return value isn't intended to be discarded. If a caller discards the return value, the compiler generates warning C4834.
Starting in the C++17 Standard, the `[[nodiscard]]` attribute specifies that a function's return value isn't intended to be discarded. If a caller discards the return value, the compiler generates warning C4834. Although this attribute was introduced in C++17, the compiler respects this attribute and generates warnings related to it when using `/std:c++14` and later.

To resolve this warning, consider why your code doesn't use the return value. Your use of the function may not match its intent. You can circumvent the warning by assigning the value to **`std::ignore`** or by casting it to **`void`** if discarding the value is intentional.
Assignment to **`std::ignore`** is preferred over casting to **`void`** in C++11 and higher, as it makes your intent clearer and will not trigger [Warning C26457](../../code-quality/c26457.md) if enabled in your code analysis settings.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
description: "Learn more about: Compiler Warning (level 4) C5266"
title: "Compiler Warning (level 4) C5266"
ms.date: 01/18/2024
f1_keywords: ["C5266"]
helpviewer_keywords: ["C5266"]
---
# Compiler Warning (level 4) C5266

> 'const' qualifier on return type has no effect

The C++ Standard specifies that a top-level const (or volatile) qualification on a function return type is ignored.

This warning is off by default.\
This warning was introduced in Visual Studio 17.6

## Example

The following sample generates C5266:

```cpp
// compile with: /W4 /c

#pragma warning(default : 5266) // enable warning C5266 because it's off by default (or compile with /w45266)

const int f() // warning C5266: 'const' qualifier on return type has no effect
{
return 13;
}
```

## See also

[Enable warnings that are off by default](../../preprocessor/compiler-warnings-that-are-off-by-default.md)
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: 02/28/2023
ms.date: 01/18/2024
helpviewer_keywords: ["warnings, by compiler version", "cl.exe compiler, setting warning options"]
---
# Compiler Warnings by compiler version
Expand Down Expand Up @@ -48,6 +48,7 @@ These versions of the compiler introduced new warnings:
| Visual Studio 2022 version 17.3 | 19.33 |
| Visual Studio 2022 version 17.4 | 19.34 |
| Visual Studio 2022 version 17.5 | 19.35 |
| Visual Studio 2022 version 17.6 | 19.36 |
| Visual Studio 2022 version 17.7 | 19.37 |

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.
Expand All @@ -64,6 +65,14 @@ These warnings, and all warnings in later versions, are suppressed by using the
|--|--|
| C5267 | definition of implicit copy constructor/assignment operator for '*type*' is deprecated because it has a user-provided assignment operator/copy constructor |

## Warnings introduced in Visual Studio 2022 version 17.6 (compiler version 19.36)

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

| Warning | Message |
|--|--|
| [C5266](compiler-warning-level-4-c5266.md) | 'const' qualifier on return type has no effect |

## 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`**.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
title: "Compiler warnings C4800 Through C5999"
description: "Table of Microsoft C/C++ compiler warnings C4800 through C5999."
ms.date: 03/01/2023
f1_keywords: ["C4808", "C4809", "C4825", "C4827", "C4837", "C4842", "C4844", "C4845", "C4846", "C4847", "C4848", "C4854", "C4855", "C4856", "C4857", "C4872", "C4880", "C4881", "C4882", "C4916", "C4921", "C4934", "C4954", "C4955", "C4963", "C4966", "C4970", "C4971", "C4973", "C4974", "C4981", "C4983", "C4987", "C4988", "C4989", "C4990", "C4991", "C4992", "C4998", "C5022", "C5023", "C5024", "C5025", "C5026", "C5027", "C5028", "C5029", "C5030", "C5031", "C5032", "C5034", "C5035", "C5036", "C5039", "C5040", "C5041", "C5042", "C5043", "C5044", "C5047", "C5048", "C5049", "C5051", "C5052", "C5053", "C5057", "C5058", "C5059", "C5060", "C5061", "C5062", "C5063", "C5081", "C5100", "C5101", "C5102", "C5103", "C5104", "C5106", "C5107", "C5108", "C5200", "C5201", "C5202", "C5203", "C5204", "C5205", "C5206", "C5207", "C5209", "C5210", "C5211", "C5212", "C5213", "C5214", "C5215", "C5216", "C5217", "C5218", "C5219", "C5220", "C5221", "C5222", "C5223", "C5224", "C5225", "C5226", "C5227", "C5228", "C5229", "C5230", "C5231", "C5232", "C5233", "C5234", "C5235", "C5236", "C5237", "C5238", "C5239", "C5241", "C5242", "C5244", "C5245", "C5246", "C5249", "C5250", "C5251", "C5252", "C5253", "C5254", "C5255", "C5256", "C5257", "C5258", "C5259", "C5260", "C5261", "C5263", "C5264", "C5300"]
helpviewer_keywords: ["C4808", "C4809", "C4825", "C4827", "C4837", "C4842", "C4844", "C4845", "C4846", "C4847", "C4848", "C4854", "C4855", "C4856", "C4857", "C4872", "C4880", "C4881", "C4882", "C4916", "C4921", "C4934", "C4954", "C4955", "C4963", "C4966", "C4970", "C4971", "C4973", "C4974", "C4981", "C4983", "C4987", "C4988", "C4989", "C4990", "C4991", "C4992", "C4998", "C5022", "C5023", "C5024", "C5025", "C5026", "C5027", "C5028", "C5029", "C5030", "C5031", "C5032", "C5034", "C5035", "C5036", "C5039", "C5040", "C5041", "C5042", "C5043", "C5044", "C5047", "C5048", "C5049", "C5051", "C5052", "C5053", "C5057", "C5058", "C5059", "C5060", "C5061", "C5062", "C5063", "C5081", "C5100", "C5101", "C5102", "C5103", "C5104", "C5106", "C5107", "C5108", "C5200", "C5201", "C5202", "C5203", "C5204", "C5205", "C5206", "C5207", "C5209", "C5210", "C5211", "C5212", "C5213", "C5214", "C5215", "C5216", "C5217", "C5218", "C5219", "C5220", "C5221", "C5222", "C5223", "C5224", "C5225", "C5226", "C5227", "C5228", "C5229", "C5230", "C5231", "C5232", "C5233", "C5234", "C5235", "C5236", "C5237", "C5238", "C5239", "C5241", "C5242", "C5244", "C5245", "C5246", "C5249", "C5250", "C5251", "C5252", "C5253", "C5254", "C5255", "C5256", "C5257", "C5258", "C5259", "C5260", "C5261", "C5263", "C5264", "C5300"]
ms.date: 01/18/2024
f1_keywords: ["C4808", "C4809", "C4825", "C4827", "C4837", "C4842", "C4844", "C4845", "C4846", "C4847", "C4848", "C4854", "C4855", "C4856", "C4857", "C4872", "C4880", "C4881", "C4882", "C4916", "C4921", "C4934", "C4954", "C4955", "C4963", "C4966", "C4970", "C4971", "C4973", "C4974", "C4981", "C4983", "C4987", "C4988", "C4989", "C4990", "C4991", "C4992", "C4998", "C5022", "C5023", "C5024", "C5025", "C5026", "C5027", "C5028", "C5029", "C5030", "C5031", "C5032", "C5034", "C5035", "C5036", "C5039", "C5040", "C5041", "C5042", "C5043", "C5044", "C5047", "C5048", "C5049", "C5051", "C5052", "C5053", "C5057", "C5058", "C5059", "C5060", "C5061", "C5062", "C5063", "C5081", "C5100", "C5101", "C5102", "C5103", "C5104", "C5106", "C5107", "C5108", "C5200", "C5201", "C5202", "C5203", "C5204", "C5205", "C5206", "C5207", "C5209", "C5210", "C5211", "C5212", "C5213", "C5214", "C5215", "C5216", "C5217", "C5218", "C5219", "C5220", "C5221", "C5222", "C5223", "C5224", "C5225", "C5226", "C5227", "C5228", "C5229", "C5230", "C5231", "C5232", "C5233", "C5234", "C5235", "C5236", "C5237", "C5238", "C5239", "C5241", "C5242", "C5244", "C5245", "C5246", "C5249", "C5250", "C5251", "C5252", "C5253", "C5254", "C5255", "C5256", "C5257", "C5258", "C5259", "C5260", "C5261", "C5263", "C5264", "C5266", "C5300"]
helpviewer_keywords: ["C4808", "C4809", "C4825", "C4827", "C4837", "C4842", "C4844", "C4845", "C4846", "C4847", "C4848", "C4854", "C4855", "C4856", "C4857", "C4872", "C4880", "C4881", "C4882", "C4916", "C4921", "C4934", "C4954", "C4955", "C4963", "C4966", "C4970", "C4971", "C4973", "C4974", "C4981", "C4983", "C4987", "C4988", "C4989", "C4990", "C4991", "C4992", "C4998", "C5022", "C5023", "C5024", "C5025", "C5026", "C5027", "C5028", "C5029", "C5030", "C5031", "C5032", "C5034", "C5035", "C5036", "C5039", "C5040", "C5041", "C5042", "C5043", "C5044", "C5047", "C5048", "C5049", "C5051", "C5052", "C5053", "C5057", "C5058", "C5059", "C5060", "C5061", "C5062", "C5063", "C5081", "C5100", "C5101", "C5102", "C5103", "C5104", "C5106", "C5107", "C5108", "C5200", "C5201", "C5202", "C5203", "C5204", "C5205", "C5206", "C5207", "C5209", "C5210", "C5211", "C5212", "C5213", "C5214", "C5215", "C5216", "C5217", "C5218", "C5219", "C5220", "C5221", "C5222", "C5223", "C5224", "C5225", "C5226", "C5227", "C5228", "C5229", "C5230", "C5231", "C5232", "C5233", "C5234", "C5235", "C5236", "C5237", "C5238", "C5239", "C5241", "C5242", "C5244", "C5245", "C5246", "C5249", "C5250", "C5251", "C5252", "C5253", "C5254", "C5255", "C5256", "C5257", "C5258", "C5259", "C5260", "C5261", "C5263", "C5264", "C5266", "C5300"]
---
# Compiler warnings C4800 through C5999

Expand Down Expand Up @@ -247,6 +247,7 @@ The articles in this section of the documentation explain a subset of the warnin
| [Compiler warning (level 1, error, off) C5262](c5262.md) | implicit fall-through occurs here; are you missing a break statement? Use `[[fallthrough]]` when a `break` statement is intentionally omitted between cases |
| Compiler warning (level 4, off) C5263 | calling '`std::move`' on a temporary object prevents copy elision |
| Compiler warning (level 4, off) C5264 | '*variable-name*': 'const' variable is not used |
| [Compiler warning (level 4, off) C5266](compiler-warning-level-4-c5266.md) | 'const' qualifier on return type has no effect |
| [Compiler warning C5267](c5267.md) | definition of implicit copy constructor/assignment operator for '*type*' is deprecated because it has a user-provided assignment operator/copy constructor |
| Compiler warning (level 1, error) C5300 | '#pragma omp atomic': left operand of '*operator*' must match left hand side of assignment-expression |
| [Compiler warning (level 1) C5301](c5301-c5302.md) | '#pragma omp for': '*loop-index*' increases while loop condition uses '*comparison*'; non-terminating loop? |
Expand Down
2 changes: 2 additions & 0 deletions docs/error-messages/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4363,6 +4363,8 @@ items:
href: compiler-warnings/c5248.md
- name: Compiler warning (level 1, error, off) C5262
href: compiler-warnings/c5262.md
- name: Compiler warning (level 4) C5266
href: compiler-warnings/compiler-warning-level-4-c5266.md
- name: Compiler warning (level 4) C5267
href: compiler-warnings/c5267.md
- name: Compiler warning (level 1) C5301 and C5302
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: "Learn more about: Compiler warnings that are off by default"
title: "Compiler warnings that are off by default"
ms.date: 11/15/2023
ms.date: 01/18/2024
helpviewer_keywords: ["warnings, compiler", "cl.exe compiler, setting options"]
---
# Compiler warnings that are off by default
Expand Down Expand Up @@ -190,6 +190,7 @@ The following warnings are turned off by default in Visual Studio 2022 and later
| [C5262](../error-messages/compiler-warnings/c5262.md) (level 1, error) | implicit fall-through occurs here; are you missing a `break` statement? Use `[[fallthrough]]` when a `break` statement is intentionally omitted between cases <sup>17.4</sup> |
| C5263 (level 4) | calling '`std::move`' on a temporary object prevents copy elision <sup>17.4</sup> |
| C5264 (level 4) | '*variable-name*': 'const' variable is not used <sup>17.4</sup> |
| [C5266 (level 4)](../error-messages/compiler-warnings/compiler-warning-level-4-c5266.md) | 'const' qualifier on return type has no effect <sup>17.6</sup> |
| [C5267](../error-messages/compiler-warnings/c5267.md) (level 4) | definition of implicit copy constructor/assignment operator for '*type*' is deprecated because it has a user-provided assignment operator/copy constructor <sup>17.7</sup> |

<sup>14.1</sup> This warning is available starting in Visual Studio 2015 Update 1.\
Expand Down