diff --git a/include/verilated_force.h b/include/verilated_force.h index 2767200e7..8160fdffb 100644 --- a/include/verilated_force.h +++ b/include/verilated_force.h @@ -222,11 +222,12 @@ public: VlForceVec() = default; template - T read(T val) const { + T read(const T& val) const { + T result = val; if VL_CONSTEXPR_CXX17 (VlForceTypeInfo::unpackedArray) { // Handling the case of a nested flattened array using recursion using ElemRef - = decltype(VlForceArrayIndexer::elem(val, static_cast(0))); + = decltype(VlForceArrayIndexer::elem(result, static_cast(0))); using Elem = VlForceBaseType; const int total = static_cast(VlForceArrayIndexer::size); for (const auto& entry : m_entries) { @@ -236,13 +237,13 @@ public: for (int idx = startIdx; idx <= endIdx; idx++) { const int rhsIndex = idx - entry.m_rhsLsb; const std::size_t uidx = static_cast(idx); - VlForceArrayIndexer::elem(val, uidx) = rhsBasep[rhsIndex]; + VlForceArrayIndexer::elem(result, uidx) = rhsBasep[rhsIndex]; } } - return val; + return result; } - applyEntries(val); - return val; + applyEntries(result); + return result; } template