diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-04-02 14:15:57 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-04-02 14:15:57 +0900 |
commit | c36f899c4485ebf602fcaf225f41c64fbea773c3 (patch) | |
tree | 485ac342bac588fcbdec28a8fb27ee2c70ae3530 | |
parent | d7725b45bfd33163840536f975853837aa8e4763 (diff) | |
download | libquotient-c36f899c4485ebf602fcaf225f41c64fbea773c3.tar.gz libquotient-c36f899c4485ebf602fcaf225f41c64fbea773c3.zip |
Be more cautious with rvalues
Clang on FreeBSD doesn't seem to be playing nice in Release
configuration. See the comment in the committed code.
-rw-r--r-- | lib/connection.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp index 2bdbb2e5..a2b1b94e 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -281,7 +281,8 @@ void Connection::sync(int timeout) void Connection::onSyncSuccess(SyncData &&data) { d->data->setLastEvent(data.nextBatch()); - for (auto&& roomData: data.takeRoomData()) + auto allRoomData = data.takeRoomData(); + for (auto&& roomData: allRoomData) { const auto forgetIdx = d->roomIdsToForget.indexOf(roomData.roomId); if (forgetIdx != -1) @@ -302,7 +303,12 @@ void Connection::onSyncSuccess(SyncData &&data) { r->updateData(std::move(roomData)); QCoreApplication::processEvents(); } - for (auto&& accountEvent: data.takeAccountData()) + // `for (auto&& accountEvent: data.takeAccountData())` doesn't work well + // with Clang on FreeBSD in Release configuration; it seems that + // the lifetime of the returned rvalue does not extend (violating the + // standard) and accountEvent refers to garbage in the loop body as a result. + auto allAccountData = data.takeAccountData(); + for (auto&& accountEvent: allAccountData) { if (accountEvent->type() == EventType::DirectChat) { |