mirror of
https://github.com/zeromq/cppzmq.git
synced 2025-05-19 20:56:56 +02:00
Merge pull request #347 from gummif/gfa/aliasing-warning
Problem: Strict aliasing warning in tests
This commit is contained in:
commit
88ada98d0b
@ -95,12 +95,12 @@ TEST_CASE("socket_ref swap", "[socket_ref]")
|
|||||||
swap(sr1, sr2);
|
swap(sr1, sr2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("socket_ref reinterpret as void*", "[socket_ref]")
|
TEST_CASE("socket_ref type punning", "[socket_ref]")
|
||||||
{
|
{
|
||||||
struct SVP
|
struct SVP
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
};
|
} svp;
|
||||||
struct SSR
|
struct SSR
|
||||||
{
|
{
|
||||||
zmq::socket_ref sr;
|
zmq::socket_ref sr;
|
||||||
@ -109,7 +109,9 @@ TEST_CASE("socket_ref reinterpret as void*", "[socket_ref]")
|
|||||||
zmq::context_t context;
|
zmq::context_t context;
|
||||||
zmq::socket_t socket(context, zmq::socket_type::router);
|
zmq::socket_t socket(context, zmq::socket_type::router);
|
||||||
CHECK(socket.handle() != nullptr);
|
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);
|
CHECK(ssr.sr == socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user