vpnor: table: Handle alignment warning

The static_assert() isn't enough for g++-9, do the slow but correct
thing and copy the data into a container with the correct alignment.

Resolves:

In file included from vpnor/table.cpp:11:
./vpnor/table.hpp: In instantiation of ‘openpower::virtual_pnor::checksum_t openpower::virtual_pnor::details::checksum(const T&) [with T = pnor_partition_table::<unnamed struct>; openpower::virtual_pnor::checksum_t = unsigned int]’:
vpnor/table.cpp:52:50:   required from here
./vpnor/table.hpp:66:10: warning: converting a packed ‘const pnor_partition_table::<unnamed struct>’ pointer (alignment 1) to a ‘const unsigned int’ pointer (alignment 4) may result in an unaligned pointer value [-Waddress-of-packed-member]
   66 |     auto begin = reinterpret_cast<const checksum_t*>(&data);
      |          ^~~~~

Change-Id: If73c72476786628f42a0cb75f43de3d3e313c414
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/vpnor/table.hpp b/vpnor/table.hpp
index 0a867ad..e42e8d8 100644
--- a/vpnor/table.hpp
+++ b/vpnor/table.hpp
@@ -2,6 +2,7 @@
 /* Copyright (C) 2018 IBM Corp. */
 #pragma once
 
+#include <cstring>
 #include <experimental/filesystem>
 #include <memory>
 #include <numeric>
@@ -51,7 +52,7 @@
 {
 
 /** @brief Compute XOR-based checksum, by XORing consecutive words
- *         in the input data. Input must be aligned to word boundary.
+ *         in the input data.
  *
  *  @param[in] data - input data on which checksum is computed
  *
@@ -63,10 +64,12 @@
     static_assert(sizeof(decltype(data)) % sizeof(checksum_t) == 0,
                   "sizeof(data) is not aligned to sizeof(checksum_t) boundary");
 
-    auto begin = reinterpret_cast<const checksum_t*>(&data);
-    auto end = begin + (sizeof(decltype(data)) / sizeof(checksum_t));
-
-    return std::accumulate(begin, end, 0, std::bit_xor<checksum_t>());
+    /* Shut the compiler up about alignment, consider alternatives */
+    const size_t n_elems = sizeof(decltype(data)) / sizeof(checksum_t);
+    checksum_t csdata[n_elems];
+    memcpy(csdata, &data, sizeof(csdata));
+    auto end = csdata + n_elems;
+    return std::accumulate(csdata, end, 0, std::bit_xor<checksum_t>());
 }
 
 } // namespace details