From 2ead07f2102fb89c7e48d6a19571006b61aa272f Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Thu, 13 Jul 2023 16:47:23 +0200 Subject: [PATCH] Explicitly specify the alignment of QUuid::Id128Bytes union ... because otherwise the union can change its alignment based on the presence of the data128 member. For example, QtBluetooth explicitly #undef's __SIZEOF_INT128__ in its removed_api.cpp, which leads to UB without this patch. Found during API review Change-Id: Ia17122cc9f3d422530cf722ea528591fce7ab7ff Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira (cherry picked from commit 0b3c5816c6d6be52918aa51178f03bd760449eb9) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/plugin/quuid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h index 299ce76d7b4..ddd24eb6786 100644 --- a/src/corelib/plugin/quuid.h +++ b/src/corelib/plugin/quuid.h @@ -55,7 +55,7 @@ public: Id128 = 3 }; - union Id128Bytes { + union alignas(16) Id128Bytes { quint8 data[16]; quint16 data16[8]; quint32 data32[4];