[gjs: 3/10] maint: Suppress cppcheck warning about accessing a variable after moving
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 3/10] maint: Suppress cppcheck warning about accessing a variable after moving
- Date: Fri, 4 Feb 2022 05:31:03 +0000 (UTC)
commit 99d81ba32659ce1fd7c5f2482b3824ee34cb3df1
Author: Philip Chimento <philip chimento gmail com>
Date: Sun Jan 16 17:16:45 2022 -0800
maint: Suppress cppcheck warning about accessing a variable after moving
This is done intentionally in this test to ensure that we don't crash, but
the warning itself makes sense because you are generally not supposed to
do this.
test/gjs-test-jsapi-utils.cpp | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/test/gjs-test-jsapi-utils.cpp b/test/gjs-test-jsapi-utils.cpp
index a99ca4236..c9263136f 100644
--- a/test/gjs-test-jsapi-utils.cpp
+++ b/test/gjs-test-jsapi-utils.cpp
@@ -290,12 +290,17 @@ static void test_gjs_autopointer_operator_move(Fixture* fx, const void*) {
g_assert_true(ptr == data);
};
+ // Accessing a value after moving out of it is bad in general, but here it
+ // is done on purpose, to test that the autoptr's move constructor empties
+ // the old autoptr.
+
test_move_fun(std::move(autoptr));
- g_assert_nonnull(autoptr);
+ g_assert_nonnull(autoptr); // cppcheck-suppress accessMoved
+ // cppcheck-suppress accessMoved
GjsAutoTestObject autoptr2 = std::move(autoptr);
g_assert_true(autoptr2 == fx->ptr);
- g_assert_null(autoptr);
+ g_assert_null(autoptr); // cppcheck-suppress accessMoved
}
static void test_gjs_autopointer_operator_swap(Fixture* fx, const void*) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]