From 577276d12c7b40d97a113a9daadcbd1f321b686f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 20 Jan 2023 13:55:31 +0100 Subject: [PATCH] tst_QUrlQuery: fix Clang 15 -Wself-move Says Clang 15: tst_qurlquery.cpp:193:11: warning: explicitly moving variable of type 'QUrlQuery' to itself [-Wself-move] moved = std::move(moved); ~~~~~ ^ ~~~~~ It's amazing how little it takes to throw this warning off guards: just use an alising reference instead of the same variable. Makes you wonder whether the time spent on detecting such trivialities in the compiler is really well spent. Amends fc8dad2f10e7976cfa778ca7d75e651012629b21. Pick-to: 6.5 Task-number: QTBUG-109842 Change-Id: I165af2a786aa0ba28b8dcd039a500f3494bc29a9 Reviewed-by: Thiago Macieira --- tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp b/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp index 4735d33eb26..2ff1ba43ae4 100644 --- a/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp +++ b/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp @@ -190,11 +190,17 @@ void tst_QUrlQuery::constructing() QCOMPARE(moved, copy); // self move-assign - moved = std::move(moved); + { + auto &self = moved; // prevent -Wself-move + moved = std::move(self); + } QCOMPARE(moved, copy); // self move-assign of moved-from (Hinnant Criterion) - other = std::move(other); + { + auto &self = other; // prevent -Wself-move + other = std::move(self); + } // shouldn't crash; here, or further down // copy-assign to moved-from object