summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin/quuid.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-06-13 13:47:18 +0200
committerMarc Mutz <marc.mutz@qt.io>2023-06-14 10:00:58 +0200
commit2bd8e63690569711452e9c56274ffe2bf91f8f5c (patch)
tree1152554c990c7da2f385184bd8b1e95a1330d714 /src/corelib/plugin/quuid.h
parent30f87c86b4790761cc117b8e5f9ead4da225b20d (diff)
QUuid: fix qSwap() use in constexpr function
I don't know why the compilers didn't shout here, but what _should_ have happened is: - qSwap<quint64>() gets instantiated - the unqualified swap() call inside gets resolved to std::swap() - std::swap() is not constexpr in C++17, so qSwap<quint64>() silently gets its constexpr dropped - error, due to the use of non-constexpr function qSwap() in constexpr function bswap() There's no way through the function that doesn't hit the qSwap(), so that is also not the explanation. And, indeed, replacing qSwap() with std::swap() gets me the expected error... Before compilers get the idea, rewrite the code to not require swapping. Amends 686c02224c03735356bdab987bf62644eb34cc34. Pick-to: 6.6 Change-Id: Ie1364bb2fd148bf995a8ffd321f77a6021176928 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/plugin/quuid.h')
-rw-r--r--src/corelib/plugin/quuid.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h
index b977446d97..3142062665 100644
--- a/src/corelib/plugin/quuid.h
+++ b/src/corelib/plugin/quuid.h
@@ -192,9 +192,10 @@ private:
static constexpr Id128Bytes bswap(Id128Bytes b)
{
// 128-bit byte swap
- b.data64[0] = qbswap(b.data64[0]);
- b.data64[1] = qbswap(b.data64[1]);
- qSwap(b.data64[0], b.data64[1]);
+ auto b0 = qbswap(b.data64[0]);
+ auto b1 = qbswap(b.data64[1]);
+ b.data64[0] = b1;
+ b.data64[1] = b0;
return b;
}
};