Skip to content

Commit bef53a1

Browse files
author
mikeblome
committed
Merge branch 'master' into mb-ide
local merge from master
2 parents f223475 + 66798ad commit bef53a1

File tree

294 files changed

+6466
-5373
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

294 files changed

+6466
-5373
lines changed

docs/atl/reference/cautovectorptr-class.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class CAutoVectorPtr
8282
|[CAutoVectorPtr::m_p](#m_p)|The pointer data member variable.|
8383

8484
## Remarks
85-
This class provides methods for creating and managing a smart pointer, which will help protect against memory leaks by automatically freeing resources when it falls out of scope. `CAutoVectorPtr` is similar to `CAutoPtr`, the only difference being that `CAutoVectorPtr` uses [vector new[]](../../standard-library/new-operators.md#operator_new_arr) and [vector delete[]](../../standard-library/new-operators.md#operator_delete_arr) to allocate and free memory instead of the C++ **new** and **delete** operators. See [CAutoVectorPtrElementTraits](../../atl/reference/cautovectorptrelementtraits-class.md) if collection classes of `CAutoVectorPtr` are required.
85+
This class provides methods for creating and managing a smart pointer, which will help protect against memory leaks by automatically freeing resources when it falls out of scope. `CAutoVectorPtr` is similar to `CAutoPtr`, the only difference being that `CAutoVectorPtr` uses [vector new[]](../../standard-library/new-operators.md#op_new_arr) and [vector delete[]](../../standard-library/new-operators.md#op_delete_arr) to allocate and free memory instead of the C++ **new** and **delete** operators. See [CAutoVectorPtrElementTraits](../../atl/reference/cautovectorptrelementtraits-class.md) if collection classes of `CAutoVectorPtr` are required.
8686

8787

8888
See [CAutoPtr](../../atl/reference/cautoptr-class.md) for an example of using a smart pointer class.

docs/build/how-to-integrate-custom-tools-into-the-project-properties.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "How to: Integrate Custom Tools into the Project Properties | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
4+
ms.date: "04/27/2016"
55
ms.reviewer: ""
66
ms.suite: ""
77
ms.technology:
@@ -45,17 +45,17 @@ You can add custom tool options to the Visual Studio **Property Pages** window b
4545

4646
1. In the XML editor, create an XML file.
4747

48-
2. Save the file in the %ProgramFiles%\MSBuild\Microsoft.Cpp\v4.0\ folder. Every rule in the **Property Pages** window is represented by an XML file in this folder. Make sure that the file is uniquely named in the folder.
48+
2. Save the file in the Visual Studio 2017 `VCTargets\1033` folder. You will have a different path for each edition of Visual Studio 2017 that is installed and each language. For example, the folder path for Visual Studio Enterprise edition in English is `%ProgramFiles%\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\1033`. Adjust the path for your language and Visual Studio edition. Every rule in the **Property Pages** window is represented by an XML file in this folder. Make sure that the file is uniquely named in the folder.
4949

50-
3. Copy the content of %ProgramFiles%\MSBuild\Microsoft.Cpp\v4.0\cl.xml, close it without saving changes, and then paste the content in your new XML file. You can use any XML schema file - this is just one that can be used so you start with a template.
50+
3. Copy the content of `%ProgramFiles%\Microsoft Visual Studio\2017\<VS Edition>\Common7\IDE\VC\VCTargets\<LCID>\cl.xml`, close it without saving changes, and then paste the content in your new XML file. You can use any XML schema file - this is just one that can be used so you start with a template.
5151

5252
4. In the new XML file, modify the content according to your requirements. Make sure to change the **Rule Name** and **Rule.DisplayName** at the top of the file.
5353

5454
5. Save the changes and close the file.
5555

56-
6. The XML files in %ProgramFiles%\MSBuild\Microsoft.Cpp\v4.0\ are loaded when Visual Studio starts. Therefore, to test the new file, restart Visual Studio.
56+
6. The XML files in `%ProgramFiles%\Microsoft Visual Studio\2017\<VS Edition>\Common7\IDE\VC\VCTargets\<LCID>` are loaded when Visual Studio starts. Therefore, to test the new file, restart Visual Studio.
5757

5858
7. In **Solution Explorer**, right-click a project and then click **Properties**. In the **Property Pages** window, in the left pane, verify that there is a new node with the name of your Rule.
5959

6060
## See Also
61-
[MSBuild (Visual C++)](../build/msbuild-visual-cpp.md)
61+
[MSBuild (Visual C++)](../build/msbuild-visual-cpp.md)

docs/build/reference/zc-throwingnew-assume-operator-new-throws.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ When the `/Zc:throwingNew` option is specified, the compiler optimizes calls to
4848

4949
## Remarks
5050

51-
Since ISO C++98, the standard has specified that the default [operator new](../../standard-library/new-operators.md#operator_new) throws `std::bad_alloc` when memory allocation fails. Versions of Visual C++ up to Visual Studio 6.0 returned a null pointer on an allocation failure. Beginning in Visual Studio 2002, `operator new` conforms to the standard and throws on failure. To support code that uses the older allocation style, Visual Studio provides a linkable implementation of `operator new` in *nothrownew.obj* that returns a null pointer on failure. By default, the compiler also generates defensive null checks to prevent these older-style allocators from causing an immediate crash on failure. The `/Zc:throwingNew` option tells the compiler to leave out these null checks, on the assumption that all linked memory allocators conform to the standard. This does not apply to explicit non-throwing `operator new` overloads, which are declared by using an additional parameter of type `std::nothrow_t` and have an explicit `noexcept` specification.
51+
Since ISO C++98, the standard has specified that the default [operator new](../../standard-library/new-operators.md#op_new) throws `std::bad_alloc` when memory allocation fails. Versions of Visual C++ up to Visual Studio 6.0 returned a null pointer on an allocation failure. Beginning in Visual Studio 2002, `operator new` conforms to the standard and throws on failure. To support code that uses the older allocation style, Visual Studio provides a linkable implementation of `operator new` in *nothrownew.obj* that returns a null pointer on failure. By default, the compiler also generates defensive null checks to prevent these older-style allocators from causing an immediate crash on failure. The `/Zc:throwingNew` option tells the compiler to leave out these null checks, on the assumption that all linked memory allocators conform to the standard. This does not apply to explicit non-throwing `operator new` overloads, which are declared by using an additional parameter of type `std::nothrow_t` and have an explicit `noexcept` specification.
5252

5353
Conceptually, to create an object on the free store, the compiler generates code to allocate its memory and then to invoke its constructor to initialize the memory. Because the Visual C++ compiler normally cannot tell if this code will be linked to a non-conforming, non-throwing allocator, by default it also generates a null check before calling the constructor. This prevents a null pointer dereference in the constructor call if a non-throwing allocation fails. In most cases, these checks are unnecessary, because the default `operator new` allocators throw instead of returning null pointers. The checks also have unfortunate side effects. They bloat the code size, they flood the branch predictor, and they inhibit other useful compiler optimizations such as devirtualization or const propagation out of the initialized object. The checks exist only to support code that links to *nothrownew.obj* or has custom non-conforming `operator new` implementations. If you do not use non-conforming `operator new`, we recommend you use `/Zc:throwingNew` to optimize your code.
5454

docs/c-runtime-library/reference/strstr-wcsstr-mbsstr-mbsstr-l.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,4 +219,4 @@ lazy found at position 36
219219
[strpbrk, wcspbrk, _mbspbrk, _mbspbrk_l](../../c-runtime-library/reference/strpbrk-wcspbrk-mbspbrk-mbspbrk-l.md)
220220
[strrchr, wcsrchr, _mbsrchr, _mbsrchr_l](../../c-runtime-library/reference/strrchr-wcsrchr-mbsrchr-mbsrchr-l.md)
221221
[strspn, wcsspn, _mbsspn, _mbsspn_l](../../c-runtime-library/reference/strspn-wcsspn-mbsspn-mbsspn-l.md)
222-
[basic_string::find](../../standard-library/basic-string-class.md#basic_string__find)
222+
[basic_string::find](../../standard-library/basic-string-class.md#find)

docs/cpp-conformance-improvements-2017.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -278,16 +278,6 @@ static_assert(test2, "PASS2");
278278
### Classes declared in anonymous namespaces
279279
According to the C++ standard, a class declared inside an anonymous namespace has internal linkage, and therefore cannot be exported. In Visual Studio 2015 and earlier, this rule was not enforced. In Visual Studio 2017 the rule is partially enforced. The following example raises this error in Visual Studio 2017: "error C2201: 'const `anonymous namespace'::S1::`vftable'': must have external linkage in order to be exported/imported."
280280

281-
```cpp
282-
namespace
283-
{
284-
struct __declspec(dllexport) S1 { virtual void f() {} }; //C2201
285-
}
286-
```
287-
288-
### Classes declared in anonymous namespaces
289-
According to the C++ standard, a class declared inside an anonymous namespace has internal linkage, and therefore cannot be exported. In Visual Studio 2015 and earlier, this rule was not enforced. In Visual Studio 2017 the rule is partially enforced. The following example raises this error in Visual Studio 2017: "error C2201: 'const `anonymous namespace'::S1::`vftable'': must have external linkage in order to be exported/imported."
290-
291281
```cpp
292282
struct __declspec(dllexport) S1 { virtual void f() {} }; //C2201
293283
```

docs/cpp/nonstandard-behavior.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void g() throw(); // parsed and used
9292
For more information on exception specifications, see [Exception Specifications](../cpp/exception-specifications-throw-cpp.md).
9393

9494
## char_traits::eof()
95-
The C++ standard states that [char_traits::eof](../standard-library/char-traits-struct.md#char_traits__eof) must not correspond to a valid `char_type` value. The Visual C++ compiler enforces this constraint for type `char`, but not for type `wchar_t`. This does not comply with the requirement in Table 62 in section 12.1.1 of the C++ ISO specification. The example below demonstrates this.
95+
The C++ standard states that [char_traits::eof](../standard-library/char-traits-struct.md#eof) must not correspond to a valid `char_type` value. The Visual C++ compiler enforces this constraint for type `char`, but not for type `wchar_t`. This does not comply with the requirement in Table 62 in section 12.1.1 of the C++ ISO specification. The example below demonstrates this.
9696

9797
```cpp
9898
#include <iostream>

docs/cppcx/strings-c-cx.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Text in the [!INCLUDE[wrt](../cppcx/includes/wrt-md.md)] is represented in C++/C
4040
## String conversions
4141
A `Platform::String` can contain only `char16` characters, or the `NULL` character. If your application has to work with 8-bit characters, use the [String::Data](../cppcx/platform-string-class.md#data) to extract the text as a `const wchar_t*`. You can then use the appropriate Windows functions or Standard Library functions to operate on the data and convert it back to a `wchar_t*` or [wstring](../standard-library/basic-string-class.md), which you can use to construct a new `Platform::String`.
4242

43-
The following code fragment shows how to convert a `String^` variable to and from a `wstring` variable. For more information about the string manipulation that's used in this example, see [basic_string::replace](../standard-library/basic-string-class.md#basic_string__replace).
43+
The following code fragment shows how to convert a `String^` variable to and from a `wstring` variable. For more information about the string manipulation that's used in this example, see [basic_string::replace](../standard-library/basic-string-class.md#replace).
4444

4545
[!code-cpp[cx_strings#04](../cppcx/codesnippet/CPP/cppcx_strings/class1.cpp#04)]
4646

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@
355355
## [Compiler Error C2276](compiler-error-c2276.md)
356356
## [Compiler Error C2277](compiler-error-c2277.md)
357357
## [Compiler Error C2279](compiler-error-c2279.md)
358+
## [Compiler Error C2280](compiler-error-c2280.md)
358359
## [Compiler Error C2283](compiler-error-c2283.md)
359360
## [Compiler Error C2285](compiler-error-c2285.md)
360361
## [Compiler Error C2286](compiler-error-c2286.md)
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
---
2+
title: "Compiler Error C2280 | Microsoft Docs"
3+
ms.custom: ""
4+
ms.date: "04/25/2017"
5+
ms.reviewer: ""
6+
ms.suite: ""
7+
ms.technology:
8+
- "devlang-cpp"
9+
ms.tgt_pltfrm: ""
10+
ms.topic: "article"
11+
f1_keywords:
12+
- "C2280"
13+
helpviewer_keywords:
14+
- "C2280"
15+
dev_langs:
16+
- "C++"
17+
ms.assetid: e6c5b1fb-2b9b-4554-8ff9-775eeb37161b
18+
caps.latest.revision: 8
19+
author: "corob-msft"
20+
ms.author: "corob"
21+
manager: "ghogen"
22+
translation.priority.ht:
23+
- "de-de"
24+
- "es-es"
25+
- "fr-fr"
26+
- "it-it"
27+
- "ja-jp"
28+
- "ko-kr"
29+
- "ru-ru"
30+
- "zh-cn"
31+
- "zh-tw"
32+
translation.priority.mt:
33+
- "cs-cz"
34+
- "pl-pl"
35+
- "pt-br"
36+
- "tr-tr"
37+
---
38+
# Compiler Error C2280
39+
40+
'*declaration*': attempting to reference a deleted function
41+
42+
The compiler detected an attempt to reference a `deleted` function. This error can be caused by a call to a member function that has been explicitly marked as `= deleted` in the source code. This error can also be caused by a call to an implicit special member function of a struct or class that is automatically declared and marked as `deleted` by the compiler. For more information about when the compiler automatically generates `default` or `deleted` special member functions, see [Special member functions](../../cpp/special-member-functions.md).
43+
44+
## Example: Explicitly deleted functions
45+
46+
A call to an explicitly `deleted` function causes this error. An explicitly `deleted` member function implies that the class or struct is intentionally designed to prevent its use, so to fix this issue, you should change your code to avoid it.
47+
48+
```cpp
49+
// C2280_explicit.cpp
50+
// compile with: cl /c /W4 C2280_explicit.cpp
51+
struct A {
52+
A();
53+
A(int) = delete;
54+
};
55+
56+
struct B {
57+
A a1;
58+
A a2 = A(3); // C2280, calls deleted A::A(int)
59+
// To fix, remove the call to A(int)
60+
};
61+
62+
void f() {
63+
B b; // calls implicit B::B(void)
64+
}
65+
```
66+
67+
## Example: Uninitialized data members
68+
69+
An uninitialized reference type data member or `const` data member causes the compiler to implicitly declare a `deleted` default constructor. To fix this issue, initialize the data member when it is declared.
70+
71+
```cpp
72+
// C2280_uninit.cpp
73+
// compile with: cl /c C2280_uninit.cpp
74+
struct A {
75+
const int i; // uninitialized const-qualified data
76+
// members or reference type data members cause
77+
// the implicit default constructor to be deleted.
78+
// To fix, initialize the value in the declaration:
79+
// const int i = 42;
80+
} a; // C2280
81+
```
82+
83+
## Example: Reference and const data members
84+
85+
A `const` or reference type data member causes the compiler to declare a `deleted` copy assignment operator. Once initialized, these members can't be assigned to, so a simple copy or move can't work. To fix this issue, we recommend you change your logic to remove the assignment operations that cause the error.
86+
87+
```cpp
88+
// C2280_ref.cpp
89+
// compile with: cl /c C2280_ref.cpp
90+
extern int k;
91+
struct A {
92+
A();
93+
int& ri = k; // a const or reference data member causes
94+
// implicit copy assignment operator to be deleted.
95+
};
96+
97+
void f() {
98+
A a1, a2;
99+
// To fix, consider removing this assignment.
100+
a2 = a1; // C2280
101+
}
102+
```
103+
104+
## Example: Movable deletes implicit copy
105+
106+
If a class declares a move constructor or move assignment operator, but does not explicitly declare a copy constructor, the compiler implicitly declares a copy constructor and defines it as `deleted`. Similarly, if a class declares a move constructor or move assignment operator, but does not explicitly declare a copy assignment operator, the compiler implicitly declares a copy assignment operator and defines it as `deleted`. To fix this issue, you must explicitly declare these members.
107+
108+
When you see error C2280 in connection with a `unique_ptr`, it is almost certainly because you are attempting to invoke its copy constructor, which is a `deleted` function. By design, a `unique_ptr` cannot be copied. Use a move constructor to transfer ownership instead.
109+
110+
```cpp
111+
// C2280_move.cpp
112+
// compile with: cl /c C2280_move.cpp
113+
class base
114+
{
115+
public:
116+
base();
117+
~base();
118+
base(base&&);
119+
// Move constructor causes copy constructor to be
120+
// implicitly declared as deleted. To fix this
121+
// issue, you can explicitly declare a copy constructor:
122+
// base(base&);
123+
// If you want the compiler default version, do this:
124+
// base(base&) = default;
125+
};
126+
127+
void copy(base *p)
128+
{
129+
base b{*p}; // C2280
130+
}
131+
```
132+
133+
## Example: Variant and volatile members
134+
135+
Versions of the compiler before Visual Studio 2015 Update 2 were non-conforming and generated default constructors and destructors for anonymous unions. These are now implicitly declared as `deleted`. Those versions also allowed non-conforming implicit definition of `default` copy and move constructors and `default` copy and move assignment operators in classes and structs that have `volatile` member variables. The compiler now considers these to have non-trivial constructors and assignment operators, and doesn't generate `default` implementations. When such a class is a member of a union, or an anonymous union inside of a class, the copy and move constructors and copy and move assignment operators of the union or class are implicitly defined as `deleted`. To fix this issue, you must explicitly declare the required special member functions.
136+
137+
```cpp
138+
// C2280_variant.cpp
139+
// compile with: cl /c C2280_variant.cpp
140+
struct A {
141+
A() = default;
142+
A(const A&);
143+
};
144+
145+
struct B {
146+
union {
147+
A a;
148+
int i;
149+
};
150+
// To fix this issue, declare the required
151+
// special member functions:
152+
// B();
153+
// B(const B& b);
154+
};
155+
156+
int main() {
157+
B b1;
158+
B b2(b1); // C2280
159+
}
160+
```
161+
162+
## Example: Indirect base members deleted
163+
164+
Versions of the compiler before Visual Studio 2015 Update 2 were non-conforming and allowed a derived class to call special member functions of indirectly-derived `private virtual` base classes. The compiler now issues compiler error C2280 when such a call is made.
165+
166+
In this example, class `top` indirectly derives from private virtual `base`. In conforming code, this makes the members of `base` inaccessible to `top`; an object of type `top` can't be default constructed or destroyed. To fix this issue in code that relied on the old compiler behavior, change the intermediate class to use `protected virtual` derivation, or change the `top` class to use direct derivation:
167+
168+
```cpp
169+
// C2280_indirect.cpp
170+
// compile with: cl /c C2280_indirect.cpp
171+
class base
172+
{
173+
protected:
174+
base();
175+
~base();
176+
};
177+
178+
class middle : private virtual base {};
179+
// Possible fix: Replace line above with:
180+
// class middle : protected virtual base {};
181+
class top : public virtual middle {}; // C4594, C4624
182+
// Another possible fix: use direct derivation:
183+
// class top : public virtual middle, private virtual base {};
184+
185+
void destroy(top *p)
186+
{
187+
delete p; // C2280
188+
}
189+
```
190+

docs/error-messages/compiler-errors-1/compiler-errors-c2200-through-c2299.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ f1_keywords:
2828
- "C2265"
2929
- "C2269"
3030
- "C2278"
31-
- "C2280"
3231
- "C2281"
3332
- "C2282"
3433
- "C2288"
@@ -54,7 +53,6 @@ helpviewer_keywords:
5453
- "C2265"
5554
- "C2269"
5655
- "C2278"
57-
- "C2280"
5856
- "C2281"
5957
- "C2282"
6058
- "C2288"
@@ -172,7 +170,7 @@ The articles in this part of the documentation contain information about a subse
172170
|[Compiler Error C2277](compiler-error-c2277.md)|'*function*': cannot take address of this member function|
173171
|Compiler Error C2278|Obsolete.|
174172
|[Compiler Error C2279](compiler-error-c2279.md)|exception specification cannot appear in a typedef declaration|
175-
|Compiler Error C2280|'*class*::*function*': attempting to reference a deleted function|
173+
|[Compiler Error C2280](compiler-error-c2280.md)|'*class*::*function*': attempting to reference a deleted function|
176174
|Compiler Error C2281|'*class*::*function*': a function can only be deleted on the first declaration|
177175
|Compiler Error C2282|'*function1*' cannot override '*function2*'|
178176
|[Compiler Error C2283](compiler-error-c2283.md)|'*identifer*': pure specifier or abstract override specifier not allowed on unnamed class/struct|

0 commit comments

Comments
 (0)