Skip to content

Commit 5cbb6e3

Browse files
TylerMSFTTylerMSFT
authored andcommitted
add new warning for VS 17.6 - C5266
1 parent d8856c2 commit 5cbb6e3

6 files changed

Lines changed: 55 additions & 9 deletions

File tree

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ helpviewer_keywords: ["C5267"]
1111
1212
## Remarks
1313

14-
The C++ Standard deprecated (but didn't remove) the implicit generation of copy and assignment operators under some conditions. The MSVC compiler still generates the copy and assignment operators under those conditions, but may change its behavior in the future if the standard removes the deprecated behavior. The purpose of this warning is to help future proof your code if the committee decides to remove this functionality.
1514

16-
The relevant sections in the C++ standard are:
17-
- [class.copy.ctor paragraph 6](https://eel.is/c++draft/class.copy.ctor#6), which says: "If the class definition does not explicitly declare a copy constructor, a nonexplicit one is declared implicitly. If the class definition declares a move constructor or move assignment operator, the implicitly declared copy constructor is defined as deleted; otherwise, it is defaulted. The latter case is deprecated if the class has a user-declared copy assignment operator or a user-declared destructor."
18-
- [Annex D D.8](https://eel.is/c++draft/depr.impldec#1), which says: "The implicit definition of a copy constructor as defaulted is deprecated if the class has a user-declared copy assignment operator or a user-declared destructor. The implicit definition of a copy assignment operator as defaulted is deprecated if the class has a user-declared copy constructor or a user-declared destructor. It's possible that future versions of C++ will specify that these implicit definitions are deleted."
15+
16+
This warning is off by default.
17+
This warning was introduced in Visual Studio 17.6
1918

2019
## Example
2120

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 | '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) | '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)