2019-02-08 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR d/89177
* src/std/digest/murmurhash.d (MurmurHash3::put): Avoid unaligned
access traps.
===================================================================
@@ -516,9 +516,11 @@ struct MurmurHash3(uint size /* 32 or 128 */ , uin
// Do main work: process chunks of `Element.sizeof` bytes.
const numElements = data.length / Element.sizeof;
const remainderStart = numElements * Element.sizeof;
- foreach (ref const Element block; cast(const(Element[]))(data[0 .. remainderStart]))
+ for (auto start = 0; start < remainderStart; start += Element.sizeof)
{
- putElement(block);
+ BufferUnion buffer;
+ buffer.data[0 .. $] = data[start .. start + Element.sizeof];
+ putElement(buffer.block);
}
// +1 for bufferLeeway Element.
element_count += (numElements + 1) * Element.sizeof;