Skip to content

Commit cb9a8a9

Browse files
Merge pull request #4908 from MicrosoftDocs/main638415448063524907sync_temp
For protected branch, push strategy should use PR and merge to target branch method to work around git push error
2 parents 8e05170 + 25d8323 commit cb9a8a9

File tree

7 files changed

+54
-14
lines changed

7 files changed

+54
-14
lines changed

docs/cpp/welcome-back-to-cpp-modern-cpp.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ title: "Welcome back to C++ - Modern C++"
33
description: "Describes the new programming idioms in Modern C++ and their rationale."
44
ms.date: 06/02/2022
55
ms.topic: "conceptual"
6-
ms.assetid: 1cb1b849-ed9c-4721-a972-fd8f3dab42e2
76
---
87
# Welcome back to C++ - Modern C++
98

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

6564
When performance optimization is needed, consider using:
6665

67-
- The [`array`](../standard-library/array-class-stl.md) type when embedding is important, for example, as a class member.
68-
6966
- 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.
70-
7167
- Sorted `vector`. For more information, see [Algorithms](../standard-library/algorithms.md).
7268

7369
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).
@@ -79,11 +75,8 @@ Before you assume that you need to write a custom algorithm for your program, fi
7975
Here are some important examples:
8076

8177
- `for_each`, the default traversal algorithm (along with range-based `for` loops).
82-
8378
- `transform`, for not-in-place modification of container elements
84-
8579
- `find_if`, the default search algorithm.
86-
8780
- `sort`, `lower_bound`, and the other default sorting and searching algorithms.
8881

8982
To write a comparator, use strict **`<`** and use *named lambdas* when you can.

docs/error-messages/compiler-warnings/c4834.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn about the cause and fixes for Compiler warning (level 1) C4834."
33
title: "Compiler warning (Level 1) C4834"
4-
ms.date: 07/26/2021
4+
ms.date: 01/18/2024
55
f1_keywords: ["C4834"]
66
helpviewer_keywords: ["C4834"]
77
---
@@ -11,7 +11,7 @@ helpviewer_keywords: ["C4834"]
1111
1212
## Remarks
1313

14-
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.
14+
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.
1515

1616
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.
1717
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.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
description: "Learn more about: Compiler Warning (level 4) C5266"
3+
title: "Compiler Warning (level 4) C5266"
4+
ms.date: 01/18/2024
5+
f1_keywords: ["C5266"]
6+
helpviewer_keywords: ["C5266"]
7+
---
8+
# Compiler Warning (level 4) C5266
9+
10+
> 'const' qualifier on return type has no effect
11+
12+
The C++ Standard specifies that a top-level const (or volatile) qualification on a function return type is ignored.
13+
14+
This warning is off by default.\
15+
This warning was introduced in Visual Studio 17.6
16+
17+
## Example
18+
19+
The following sample generates C5266:
20+
21+
```cpp
22+
// compile with: /W4 /c
23+
24+
#pragma warning(default : 5266) // enable warning C5266 because it's off by default (or compile with /w45266)
25+
26+
const int f() // warning C5266: 'const' qualifier on return type has no effect
27+
{
28+
return 13;
29+
}
30+
```
31+
32+
## See also
33+
34+
[Enable warnings that are off by default](../../preprocessor/compiler-warnings-that-are-off-by-default.md)

docs/error-messages/compiler-warnings/compiler-warnings-by-compiler-version.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Compiler Warnings by compiler version"
33
description: "Table of Microsoft C/C++ compiler warnings by compiler version."
4-
ms.date: 02/28/2023
4+
ms.date: 01/18/2024
55
helpviewer_keywords: ["warnings, by compiler version", "cl.exe compiler, setting warning options"]
66
---
77
# Compiler Warnings by compiler version
@@ -48,6 +48,7 @@ These versions of the compiler introduced new warnings:
4848
| Visual Studio 2022 version 17.3 | 19.33 |
4949
| Visual Studio 2022 version 17.4 | 19.34 |
5050
| Visual Studio 2022 version 17.5 | 19.35 |
51+
| Visual Studio 2022 version 17.6 | 19.36 |
5152
| Visual Studio 2022 version 17.7 | 19.37 |
5253

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

68+
## Warnings introduced in Visual Studio 2022 version 17.6 (compiler version 19.36)
69+
70+
These warnings, and all warnings in later versions, are suppressed by using the compiler option **`/Wv:19.35`**.
71+
72+
| Warning | Message |
73+
|--|--|
74+
| [C5266](compiler-warning-level-4-c5266.md) | 'const' qualifier on return type has no effect |
75+
6776
## Warnings introduced in Visual Studio 2022 version 17.5 (compiler version 19.35)
6877

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

docs/error-messages/compiler-warnings/compiler-warnings-c4800-through-c4999.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: "Compiler warnings C4800 Through C5999"
33
description: "Table of Microsoft C/C++ compiler warnings C4800 through C5999."
4-
ms.date: 03/01/2023
5-
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"]
6-
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"]
4+
ms.date: 01/18/2024
5+
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"]
6+
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"]
77
---
88
# Compiler warnings C4800 through C5999
99

@@ -247,6 +247,7 @@ The articles in this section of the documentation explain a subset of the warnin
247247
| [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 |
248248
| Compiler warning (level 4, off) C5263 | calling '`std::move`' on a temporary object prevents copy elision |
249249
| Compiler warning (level 4, off) C5264 | '*variable-name*': 'const' variable is not used |
250+
| [Compiler warning (level 4, off) C5266](compiler-warning-level-4-c5266.md) | 'const' qualifier on return type has no effect |
250251
| [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 |
251252
| Compiler warning (level 1, error) C5300 | '#pragma omp atomic': left operand of '*operator*' must match left hand side of assignment-expression |
252253
| [Compiler warning (level 1) C5301](c5301-c5302.md) | '#pragma omp for': '*loop-index*' increases while loop condition uses '*comparison*'; non-terminating loop? |

docs/error-messages/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4363,6 +4363,8 @@ items:
43634363
href: compiler-warnings/c5248.md
43644364
- name: Compiler warning (level 1, error, off) C5262
43654365
href: compiler-warnings/c5262.md
4366+
- name: Compiler warning (level 4) C5266
4367+
href: compiler-warnings/compiler-warning-level-4-c5266.md
43664368
- name: Compiler warning (level 4) C5267
43674369
href: compiler-warnings/c5267.md
43684370
- name: Compiler warning (level 1) C5301 and C5302

docs/preprocessor/compiler-warnings-that-are-off-by-default.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn more about: Compiler warnings that are off by default"
33
title: "Compiler warnings that are off by default"
4-
ms.date: 11/15/2023
4+
ms.date: 01/18/2024
55
helpviewer_keywords: ["warnings, compiler", "cl.exe compiler, setting options"]
66
---
77
# Compiler warnings that are off by default
@@ -190,6 +190,7 @@ The following warnings are turned off by default in Visual Studio 2022 and later
190190
| [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> |
191191
| C5263 (level 4) | calling '`std::move`' on a temporary object prevents copy elision <sup>17.4</sup> |
192192
| C5264 (level 4) | '*variable-name*': 'const' variable is not used <sup>17.4</sup> |
193+
| [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> |
193194
| [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> |
194195

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

0 commit comments

Comments
 (0)