Skip to content

Commit 3636700

Browse files
author
Colin Robertson
committed
Add info for MFC exceptions to C2316
1 parent 9784ea8 commit 3636700

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@ translation.priority.mt:
3636
- "tr-tr"
3737
---
3838
# Compiler Error C2316
39-
'exception' : cannot be caught as the destructor and/or copy constructor are inaccessible
39+
40+
> '*exception*' : cannot be caught as the destructor and/or copy constructor are inaccessible
4041
41-
An exception was caught by value or by reference but the copy constructor and/or the assignment operator were inaccessible.
42+
An exception was caught by value or by reference but the copy constructor and/or the assignment operator were inaccessible.
4243

43-
This code was accepted by the previous version's compiler but now gives an error.
44+
This code was accepted by versions of Visual C++ before Visual Studio 2003, but now gives an error.
45+
46+
Conformance changes in Visual Studio 2015 made this error apply to bad catch statements of MFC exceptions derived from `CException`. Because `CException` has an inherited private copy constructor, the class and its derivatives are non-copyable, and cannot be passed by value, which also means they cannot be caught by value. Catch statements that caught MFC exceptions by value previously led to uncaught exceptions at runtime, but now the compiler correctly identifies this situation and reports error C2316. To fix this issue, we recommend you use the MFC TRY/CATCH macros rather than write your own exception handlers, but if that's not appropriate for your code, catch MFC exceptions by reference instead.
4447

4548
## Example
4649
The following sample generates C2316:

0 commit comments

Comments
 (0)