diff --git a/beast/strings/impl/String.cpp b/beast/strings/impl/String.cpp index c2c0fd175..a25d1340b 100644 --- a/beast/strings/impl/String.cpp +++ b/beast/strings/impl/String.cpp @@ -37,6 +37,7 @@ #include #include +#include namespace beast { @@ -240,8 +241,9 @@ private: static inline StringHolder* bufferFromText (const CharPointerType text) noexcept { // (Can't use offsetof() here because of warnings about this not being a POD) - return reinterpret_cast (reinterpret_cast (text.getAddress()) - - (reinterpret_cast (reinterpret_cast (1)->text) - 1)); + auto const text_offset = reinterpret_cast(empty.text) - reinterpret_cast(&empty); + auto const tmp = reinterpret_cast(text.getAddress()) - text_offset; + return static_cast(std::memmove(tmp, tmp, 0)); } };