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:
parent
5c538cca02
commit
39b505ee95
@ -732,7 +732,7 @@ namespace uuids
|
|||||||
|
|
||||||
uuid operator()()
|
uuid operator()()
|
||||||
{
|
{
|
||||||
uint8_t bytes[16];
|
alignas(uint32_t) uint8_t bytes[16];
|
||||||
for (int i = 0; i < 16; i += 4)
|
for (int i = 0; i < 16; i += 4)
|
||||||
*reinterpret_cast<uint32_t*>(bytes + i) = distribution(*generator);
|
*reinterpret_cast<uint32_t*>(bytes + i) = distribution(*generator);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user