Skip to content

Commit 2d84c6e

Browse files
author
Colin Robertson
authored
Update c26447.md
Add description metadata, style fixes, Acrolinx.
1 parent 29b461f commit 2d84c6e

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

docs/code-quality/c26447.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
---
22
title: C26447
3-
ms.date: 03/22/2018
3+
description: "Microsoft C++ Code Analysis warning C26447 for the C++ Core Guidelines case F.6."
4+
ms.date: 08/25/2020
45
ms.topic: reference
56
f1_keywords: ["C26447"]
67
helpviewer_keywords: ["C26447"]
78
---
89
# C26447 DONT_THROW_IN_NOEXCEPT
910

10-
The function is declared **`noexcept`** but calls a function that may throw exceptions.
11+
> The function is declared `noexcept` but calls function *function_name* that may throw exceptions (f.6).
1112
12-
C++ Core Guidelines:
13+
C++ Core Guidelines:\
1314
[F.6: If your function may not throw, declare it noexcept](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#f6-if-your-function-may-not-throw-declare-it-noexcept).
1415

15-
This rule amends another rule, [C26440 DECLARE_NOEXCEPT](c26440.md), which tries to find functions that are good candidates to be marked as **`noexcept`**. In this case, the idea is that once some function is marked as **`noexcept`**, it must keep its contract by not invoking other code that may throw exceptions.
16+
## Remarks
17+
18+
This rule amends another rule, [C26440 DECLARE_NOEXCEPT](c26440.md), which tries to find functions that are good candidates to mark as **`noexcept`**. In this case, the idea is that once you mark some function as **`noexcept`**, it must keep its contract by not invoking other code that may throw exceptions.
1619

1720
- The Microsoft C++ compiler already handles straightforward violations like **`throw`** statements in the function body (see [C4297](/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4297)).
18-
- The rule focuses only on function calls. It flags targets that are not **`constexpr`** and that can potentially throw exceptions; in other words they are not marked explicitly as non-throwing by using **`noexcept`**, **`__declspec(nothrow)`**, **throw()**.
21+
- The rule focuses only on function calls. It flags targets that aren't **`constexpr`** and that can potentially throw exceptions. In other words, they aren't marked explicitly as non-throwing by using **`noexcept`**, **`__declspec(nothrow)`**, or **throw()**.
1922
- The compiler-generated target functions are skipped to reduce noise since exception specifications are not always provided by the compiler.
20-
- The checker also skips special kinds of target functions that are expected to be implemented as **`noexcept`**; this rule is enforced by [C26439 SPECIAL_NOEXCEPT](c26439.md).
23+
- The checker also skips special kinds of target functions we expect you to implement as **`noexcept`**; this rule is enforced by [C26439 SPECIAL_NOEXCEPT](c26439.md).
2124

2225
## Example
26+
2327
```cpp
2428
#include <vector>
2529
#include <string>
@@ -33,4 +37,9 @@ std::vector<std::string> collect(std::istream& is) noexcept
3337
return res;
3438
}
3539
```
36-
You can fix these warnings by removing noexcept from the function signature.
40+
41+
You can fix these warnings by removing **`noexcept`** from the function signature.
42+
43+
## See also
44+
45+
[C26440 DECLARE_NOEXCEPT](c26440.md)

0 commit comments

Comments
 (0)