From 39b505ee95c5cc6dd77565737523bf06ed12a200 Mon Sep 17 00:00:00 2001 From: "Arthur.e" Date: Mon, 4 Apr 2022 10:58:40 -0700 Subject: [PATCH] I believe this fixes an alignment issue. Casting the uint8_t array to a uint32_t pointer may cause it to become misaligned. So making it alignas a uint32 array should remove the undefined behavior. --- include/uuid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uuid.h b/include/uuid.h index 600846f..940508b 100644 --- a/include/uuid.h +++ b/include/uuid.h @@ -732,7 +732,7 @@ namespace uuids uuid operator()() { - uint8_t bytes[16]; + alignas(uint32_t) uint8_t bytes[16]; for (int i = 0; i < 16; i += 4) *reinterpret_cast(bytes + i) = distribution(*generator);