diff --git a/include/ircd/util/bswap.h b/include/ircd/util/bswap.h index 74d4819f0..677d769f1 100644 --- a/include/ircd/util/bswap.h +++ b/include/ircd/util/bswap.h @@ -138,11 +138,18 @@ ircd::util::bswap(T *const val) noexcept { assert(val != nullptr); - const auto ptr + const auto &src { - reinterpret_cast(val) + reinterpret_cast(val) }; - std::reverse(ptr, ptr + sizeof(T)); + T tmp; + const auto &dst + { + reinterpret_cast(&tmp) + }; + + std::reverse_copy(src, src + sizeof(T), dst); + *val = tmp; return *val; }