From aaf829bfb124fcd7953c33f38154027537efb072 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 29 Nov 2019 07:07:08 -0800 Subject: [PATCH] Fix fallback pointer formatting on big endian, take 2 --- include/fmt/format.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 5a9ac298..3a48f21f 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -231,7 +231,10 @@ struct fallback_uintptr { fallback_uintptr() = default; explicit fallback_uintptr(const void* p) { *this = bit_cast(p); - if (is_big_endian()) std::memmove(value, value, sizeof(void*)); + if (is_big_endian()) { + for (size_t i = 0, j = sizeof(void*) - 1; i < j; ++i, --j) + std::swap(value[i], value[j]); + } } }; #ifdef UINTPTR_MAX