Merge pull request #347 from gummif/gfa/aliasing-warning

Problem: Strict aliasing warning in tests
This commit is contained in:
Simon Giesecke 2019-09-11 13:13:11 +02:00 committed by GitHub
commit 88ada98d0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,12 +95,12 @@ TEST_CASE("socket_ref swap", "[socket_ref]")
swap(sr1, sr2);
}
TEST_CASE("socket_ref reinterpret as void*", "[socket_ref]")
TEST_CASE("socket_ref type punning", "[socket_ref]")
{
struct SVP
{
void *p;
};
} svp;
struct SSR
{
zmq::socket_ref sr;
@ -109,7 +109,9 @@ TEST_CASE("socket_ref reinterpret as void*", "[socket_ref]")
zmq::context_t context;
zmq::socket_t socket(context, zmq::socket_type::router);
CHECK(socket.handle() != nullptr);
reinterpret_cast<SVP *>(&ssr)->p = socket.handle();
svp.p = socket.handle();
// static_cast to silence incorrect warning
std::memcpy(static_cast<void*>(&ssr), &svp, sizeof(ssr));
CHECK(ssr.sr == socket);
}