From ed369c06504812a715367da2bdf277033bf20c92 Mon Sep 17 00:00:00 2001 From: Jeffrey Song Date: Sun, 12 Jul 2026 19:22:59 -0700 Subject: [PATCH] Use snprintf for random unique indexes Replace sprintf with VL_SNPRINTF when formatting unique-array SMT select indexes. Apple clang marks sprintf deprecated under the current SDK, and --enable-ccwarn promotes that warning to an error when tests compile verilated_random.cpp. Evidence: t_process.py failed before the change at include/verilated_random.cpp:499 with -Wdeprecated-declarations; after the change, t_process.py and t_randomize_unique_elem.py pass. --- include/verilated_random.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/verilated_random.cpp b/include/verilated_random.cpp index e94288fcf..6440067be 100644 --- a/include/verilated_random.cpp +++ b/include/verilated_random.cpp @@ -496,7 +496,7 @@ bool VlRandomizer::next(VlRNG& rngr) { std::string distinctExpr = "(__Vbv (distinct"; for (uint32_t i = 0; i < size; ++i) { char hexIdx[12]; - sprintf(hexIdx, "#x%08x", i); + (void)VL_SNPRINTF(hexIdx, sizeof(hexIdx), "#x%08x", i); distinctExpr += " (select " + it->first + " " + hexIdx + ")"; } distinctExpr += "))";