diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2023-06-24 19:41:15 +0300 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2023-06-28 01:09:58 +0300 |
commit | 3a9526468c134b68b64b9a3bb6278d47c266e381 (patch) | |
tree | 95bb05fc7648b4eb8c9c6324fa4ba9ac65eb851b /tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp | |
parent | 70a7a695fdbaccd042aa4371cbb231ced2d9b499 (diff) |
Handle a couple of GCC 13 warnings about dangling references
There are two temporaries, reply.arguments() returns a temporary QList
and list.at(0) returns a temporary reference to the first element. The
local reference variable would only extend the lifetime of the temporary
object it's bound to, list.at(0), but not the temporary list itself.
Even though this a false positive in this case because QList is
implicilty shared, the compiler can't tell the difference and the fix is
simple.
tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp:1845:21:
warning: possibly dangling reference to a temporary
[-Wdangling-reference]
1845 | const QVariant &retval = reply.arguments().at(0);
| ^~~~~~
tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp:1845:50:
note: the temporary was destroyed at the end of the full expression
‘QDBusMessage::arguments() const().QList<QVariant>::at(0)’
1845 | const QVariant &retval = reply.arguments().at(0);
| ~~~~~~~~~~~~~~~~~~~~^~~
Pick-to: 6.6 6.5 5.15
Change-Id: I03d54b56769cbd0f9f1165e4679ec4947267181a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp')
-rw-r--r-- | tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp index d1b220127c..78610fd2d2 100644 --- a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp +++ b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp @@ -1842,8 +1842,7 @@ void tst_QDBusAbstractAdaptor::typeMatching() QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); QCOMPARE(reply.arguments().size(), 1); - const QVariant &retval = reply.arguments().at(0); - QVERIFY(compare(retval, value)); + QVERIFY(compare(reply.arguments().at(0), value)); } void tst_QDBusAbstractAdaptor::methodWithMoreThanOneReturnValue() |