From 4323ce04e46734ec7026978a9bcfecdeafa83cfb Mon Sep 17 00:00:00 2001 From: smathis Date: Mon, 18 May 2026 08:30:04 +0200 Subject: [PATCH] Fixed bug when putting int64_t --- bus/m_epics_ca.tpp | 3 ++- test/m_epics_ca_test.cxx | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bus/m_epics_ca.tpp b/bus/m_epics_ca.tpp index c1bd3d6..f9ed597 100644 --- a/bus/m_epics_ca.tpp +++ b/bus/m_epics_ca.tpp @@ -574,7 +574,8 @@ int mEpicsCa::put(V *value) { // it as a double. This means we have some loss of precision for large // integers, but it is the best we can do ... if (ca_field_type(_pChanID) == DBF_DOUBLE) { - return putRaw(static_cast(*value)); + double dval = static_cast(*value); + return putRaw(&dval); } else { return putRaw(value); } diff --git a/test/m_epics_ca_test.cxx b/test/m_epics_ca_test.cxx index 7d34b8f..f3f78a8 100644 --- a/test/m_epics_ca_test.cxx +++ b/test/m_epics_ca_test.cxx @@ -298,6 +298,14 @@ int main() { EQUAL(status, CM_SUCCESS); EQUAL(int_val, new_int_val); + // Write an int64 to a record and read it to check + int64_t new_int64_val = 1111; + status = int64_ca.put(&new_int64_val); + EQUAL(status, CM_SUCCESS); + status = int64_ca.get(&int64_val); + EQUAL(status, CM_SUCCESS); + EQUAL(int64_val, new_int64_val); + // Write to the limit field of the longin record new_int_val = 40; status = int_hopr_ca.put(&new_int_val);