Skip to content

Latest commit

 

History

History
20 lines (16 loc) · 1.5 KB

File metadata and controls

20 lines (16 loc) · 1.5 KB
title C26447
ms.date 03/22/2018
ms.topic reference
f1_keywords
C26447
helpviewer_keywords
C26447

C26447 DONT_THROW_IN_NOEXCEPT

The function is declared noexcept but calls a function that may throw exceptions.

C++ Core Guidelines: F.6: If your function may not throw, declare it noexcept.

This rule amends another rule, C26440 DECLARE_NOEXCEPT, 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.

  • The Microsoft C++ compiler already handles straightforward violations like throw statements in the function body (see C4297).
  • 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().
  • The compiler-generated target functions are skipped to reduce noise since exception specifications are not always provided by the compiler.
  • 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.