Skip to content

Commit 7dab204

Browse files
authored
std.cfg: Added support for std::terminate() (#6334)
1 parent 24be0e5 commit 7dab204

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

cfg/std.cfg

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@
6363
<!-- errno_t is a typedef for int -->
6464
<define name="errno_t" value="int"/>
6565
<!-- void abort(void); -->
66-
<function name="abort,std::abort">
66+
<!-- void std::terminate(); (until C++11) -->
67+
<!-- [[noreturn]] void std::terminate() noexcept; (since C++11) -->
68+
<function name="abort,std::abort,std::terminate">
6769
<noreturn>true</noreturn>
6870
</function>
6971
<!-- int abs(int j); -->

test/cfg/std.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@
5858
#include <span>
5959
#endif
6060

61+
void unreachableCode_std_terminate(int &x)
62+
{
63+
std::terminate();
64+
// cppcheck-suppress unreachableCode
65+
x=42;
66+
}
67+
6168
bool ignoredReturnValue_std_filesystem_exists(const std::filesystem::path &path, std::error_code& ec)
6269
{
6370
// cppcheck-suppress ignoredReturnValue
@@ -554,7 +561,7 @@ void bufferAccessOutOfBounds_std_ifstream_get(std::ifstream& in, std::streambuf&
554561
in.getline(cBuf, 100, 'a');
555562

556563
in.get(sb, 'a');
557-
564+
558565
in.close();
559566
}
560567

0 commit comments

Comments
 (0)