From 40acac1c5722bd6bd68819fa7e59882cd573b0e3 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 27 Mar 2025 19:00:43 -0400 Subject: [PATCH] Fix queue accessing past end (Clang 20 GLIBC warning) --- include/verilated_types.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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]; }