diff --git a/src/systemc/core/list.hh b/src/systemc/core/list.hh index b1c5f55211..6ba28259cd 100644 --- a/src/systemc/core/list.hh +++ b/src/systemc/core/list.hh @@ -102,8 +102,13 @@ struct NodeList : public ListNode prevListNode = t; } - T *getNext() { return dynamic_cast(nextListNode); } - bool empty() { return getNext() == nullptr; } + T * + getNext() + { + return empty() ? nullptr : static_cast(nextListNode); + } + + bool empty() { return nextListNode == this; } }; } // namespace sc_gem5