Commit 7a46e6ee authored by Daniel Xu's avatar Daniel Xu Committed by Facebook Github Bot

Appease gcc-8 warnings (#869)

Summary:
GCC 8 introduces a new `class-memaccess` warning. The compiler rightly complains about `memcpy`-ing a non-POD datatype even though we know it's ok. Casting to `void*` before `memcpy` silences the compiler warning.
Closes https://github.com/facebook/folly/pull/869

Reviewed By: simpkins

Differential Revision: D8475831

Pulled By: danobi

fbshipit-source-id: c0f4eb9a653803cc912be1c6148f50ab71a8c6ab
parent 3364a725
...@@ -68,13 +68,13 @@ class AtomicStruct { ...@@ -68,13 +68,13 @@ class AtomicStruct {
// we expect the compiler to optimize away the memcpy, but without // we expect the compiler to optimize away the memcpy, but without
// it we would violate strict aliasing rules // it we would violate strict aliasing rules
Raw d = 0; Raw d = 0;
memcpy(&d, &v, sizeof(T)); memcpy(&d, static_cast<void*>(&v), sizeof(T));
return d; return d;
} }
static T decode(Raw d) noexcept { static T decode(Raw d) noexcept {
T v; T v;
memcpy(&v, &d, sizeof(T)); memcpy(static_cast<void*>(&v), &d, sizeof(T));
return v; return v;
} }
......
...@@ -195,7 +195,7 @@ bool setThreadName(pthread_t pid, StringPiece name) { ...@@ -195,7 +195,7 @@ bool setThreadName(pthread_t pid, StringPiece name) {
// std::thread::native_handle_type, which means we can do unsafe things to // std::thread::native_handle_type, which means we can do unsafe things to
// extract it. // extract it.
std::thread::id id; std::thread::id id;
std::memcpy(&id, &pid, sizeof(id)); std::memcpy(static_cast<void*>(&id), &pid, sizeof(id));
return setThreadName(id, name); return setThreadName(id, name);
#endif #endif
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment