diff --git a/include/verilated_types.h b/include/verilated_types.h index bbda7da92..8a1d73df8 100644 --- a/include/verilated_types.h +++ b/include/verilated_types.h @@ -621,11 +621,13 @@ public: T_Value& atWriteAppend(int32_t index) { // cppcheck-suppress variableScope static thread_local T_Value t_throwAway; - if (VL_UNLIKELY(index < 0 || index > m_deque.size())) { + if (VL_UNLIKELY(index < 0 || index >= m_deque.size())) { + if (index == m_deque.size()) { + push_back(atDefault()); + return m_deque[index]; + } t_throwAway = atDefault(); return t_throwAway; - } else if (VL_UNLIKELY(index == m_deque.size())) { - push_back(atDefault()); } return m_deque[index]; }