Patch for GCC12
diff --git a/doc/zmq_socket_monitor_versioned.txt b/doc/zmq_socket_monitor_versioned.txt
index 5339f404a4..e71dd3544d 100644
--- a/doc/zmq_socket_monitor_versioned.txt
+++ b/doc/zmq_socket_monitor_versioned.txt
@@ -244,7 +244,7 @@ EXAMPLE
 //  in case of error.
 
 static uint64_t
-get_monitor_event (void *monitor, uint64_t *value, char **local_address, char **remote_address)
+get_monitor_event (void *monitor, uint64_t **value, char **local_address, char **remote_address)
 {
     //  First frame in message contains event number
     zmq_msg_t msg;
@@ -267,6 +267,11 @@ get_monitor_event (void *monitor, uint64_t *value, char **local_address, char **
     memcpy (&value_count, zmq_msg_data (&msg), sizeof (value_count));
     zmq_msg_close (&msg);
 
+    if (value) {
+        *value = (uint64_t *) malloc (value_count * sizeof (uint64_t));
+        assert (*value);
+    }
+
     for (uint64_t i = 0; i < value_count; ++i) {
         //  Subsequent frames in message contain event values
         zmq_msg_init (&msg);
@@ -274,8 +279,8 @@ get_monitor_event (void *monitor, uint64_t *value, char **local_address, char **
             return -1;              //  Interrupted, presumably
         assert (zmq_msg_more (&msg));
 
-        if (value_ && value_ + i)
-            memcpy (value_ + i, zmq_msg_data (&msg), sizeof (*value_));
+        if (value && *value)
+            memcpy (&(*value)[i], zmq_msg_data (&msg), sizeof (uint64_t));
         zmq_msg_close (&msg);
     }
 
diff --git a/tests/test_monitor.cpp b/tests/test_monitor.cpp
index b9309e6df3..7398dbd8d0 100644
--- a/tests/test_monitor.cpp
+++ b/tests/test_monitor.cpp
@@ -396,17 +396,19 @@ void test_monitor_versioned_stats (bind_function_t bind_function_,
     for (int i = 0; i < pulls_count; ++i) {
         char *push_local_address = NULL;
         char *push_remote_address = NULL;
-        uint64_t queue_stat[2];
+        uint64_t *queue_stat = NULL;
         int64_t event = get_monitor_event_v2 (
-          push_mon, queue_stat, &push_local_address, &push_remote_address);
+          push_mon, &queue_stat, &push_local_address, &push_remote_address);
         TEST_ASSERT_EQUAL_STRING (server_endpoint, push_local_address);
         TEST_ASSERT_EQUAL_STRING_LEN (expected_prefix_, push_remote_address,
                                       strlen (expected_prefix_));
         TEST_ASSERT_EQUAL_INT (ZMQ_EVENT_PIPES_STATS, event);
+        TEST_ASSERT_NOT_NULL (queue_stat);
         TEST_ASSERT_EQUAL_INT (i == 0 ? 0 : send_hwm, queue_stat[0]);
         TEST_ASSERT_EQUAL_INT (0, queue_stat[1]);
         free (push_local_address);
         free (push_remote_address);
+        free (queue_stat);
     }
 
     //  Close client and server
diff --git a/tests/testutil_monitoring.cpp b/tests/testutil_monitoring.cpp
index 06406270a0..8668caee83 100644
--- a/tests/testutil_monitoring.cpp
+++ b/tests/testutil_monitoring.cpp
@@ -207,7 +207,7 @@ int expect_monitor_event_multiple (void *server_mon_,
 }
 
 static int64_t get_monitor_event_internal_v2 (void *monitor_,
-                                              uint64_t *value_,
+                                              uint64_t **value_,
                                               char **local_address_,
                                               char **remote_address_,
                                               int recv_flag_)
@@ -239,6 +239,12 @@ static int64_t get_monitor_event_internal_v2 (void *monitor_,
     memcpy (&value_count, zmq_msg_data (&msg), sizeof (value_count));
     zmq_msg_close (&msg);
 
+    if (value_) {
+        *value_ =
+          (uint64_t *) malloc ((size_t) value_count * sizeof (uint64_t));
+        TEST_ASSERT_NOT_NULL (*value_);
+    }
+
     for (uint64_t i = 0; i < value_count; ++i) {
         //  Subsequent frames in message contain event values
         zmq_msg_init (&msg);
@@ -249,8 +255,8 @@ static int64_t get_monitor_event_internal_v2 (void *monitor_,
         TEST_ASSERT_TRUE (zmq_msg_more (&msg));
         TEST_ASSERT_EQUAL_UINT (sizeof (uint64_t), zmq_msg_size (&msg));
 
-        if (value_ && value_ + i)
-            memcpy (value_ + i, zmq_msg_data (&msg), sizeof (*value_));
+        if (value_ && *value_)
+            memcpy (&(*value_)[i], zmq_msg_data (&msg), sizeof (uint64_t));
         zmq_msg_close (&msg);
     }
 
@@ -266,7 +272,7 @@ static int64_t get_monitor_event_internal_v2 (void *monitor_,
 }
 
 static int64_t get_monitor_event_with_timeout_v2 (void *monitor_,
-                                                  uint64_t *value_,
+                                                  uint64_t **value_,
                                                   char **local_address_,
                                                   char **remote_address_,
                                                   int timeout_)
@@ -299,7 +305,7 @@ static int64_t get_monitor_event_with_timeout_v2 (void *monitor_,
 }
 
 int64_t get_monitor_event_v2 (void *monitor_,
-                              uint64_t *value_,
+                              uint64_t **value_,
                               char **local_address_,
                               char **remote_address_)
 {
diff --git a/tests/testutil_monitoring.hpp b/tests/testutil_monitoring.hpp
index a69db29015..eb6817d3c1 100644
--- a/tests/testutil_monitoring.hpp
+++ b/tests/testutil_monitoring.hpp
@@ -67,7 +67,7 @@ int expect_monitor_event_multiple (void *server_mon_,
                                    bool optional_ = false);
 
 int64_t get_monitor_event_v2 (void *monitor_,
-                              uint64_t *value_,
+                              uint64_t **value_,
                               char **local_address_,
                               char **remote_address_);
 

