From f141cf5bfcce7be8726bee75cf66f38ef20c517b Mon Sep 17 00:00:00 2001 From: Todd Neal Date: Thu, 5 Mar 2015 08:05:02 -0600 Subject: [PATCH] Fix a misaligned load The issue was discovered by clang: zmq.hpp:504:34: runtime error: load of misaligned address 0x2b38beb224b2 for type 'int32_t' (aka 'int'), which requires 4 byte alignment I modified the loads of both event and value to be consistent. --- zmq.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zmq.hpp b/zmq.hpp index 2af0956..3337429 100644 --- a/zmq.hpp +++ b/zmq.hpp @@ -500,8 +500,8 @@ namespace zmq #if ZMQ_VERSION_MAJOR >= 4 const char* data = static_cast(zmq_msg_data(&eventMsg)); zmq_event_t msgEvent; - msgEvent.event = *(uint16_t*)data; data += sizeof(uint16_t); - msgEvent.value = *(int32_t*)data; + memcpy(&msgEvent.event, data, sizeof(uint16_t)); data += sizeof(uint16_t); + memcpy(&msgEvent.value, data, sizeof(int32_t)); zmq_event_t* event = &msgEvent; #else zmq_event_t* event = static_cast(zmq_msg_data(&eventMsg));