From 58b50b7737745e3ce2746496f92790c035c8bed8 Mon Sep 17 00:00:00 2001 From: Ryszard Rozak Date: Fri, 27 Oct 2023 12:00:52 +0200 Subject: [PATCH] Handle nullptr in dynamic cast Signed-off-by: Ryszard Rozak --- include/verilated_types.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/verilated_types.h b/include/verilated_types.h index 0a92725a9e..54d652f70c 100644 --- a/include/verilated_types.h +++ b/include/verilated_types.h @@ -1685,6 +1685,10 @@ class VlClassRef final { template static inline bool VL_CAST_DYNAMIC(VlClassRef in, VlClassRef& outr) { + if (!in) { + outr = VlNull{}; + return true; + } VlClassRef casted = in.template dynamicCast(); if (VL_LIKELY(casted)) { outr = casted;