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.
This commit is contained in:
Arthur.e 2022-04-04 10:58:40 -07:00
parent 5c538cca02
commit 39b505ee95

View File

@ -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<uint32_t*>(bytes + i) = distribution(*generator);