From 913f25f1fc27e7871be3e80e57b7bb84be063138 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 1 May 2026 12:16:09 +0100 Subject: [PATCH] Guard void pointer conversion --- cpp2rust/converter/models/converter_refcount.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp2rust/converter/models/converter_refcount.cpp b/cpp2rust/converter/models/converter_refcount.cpp index 561bb1bb..9acd0611 100644 --- a/cpp2rust/converter/models/converter_refcount.cpp +++ b/cpp2rust/converter/models/converter_refcount.cpp @@ -1149,7 +1149,8 @@ bool ConverterRefCount::VisitExplicitCastExpr(clang::ExplicitCastExpr *expr) { case clang::Stmt::CXXStaticCastExprClass: if (!VisitFunctionPointerCast(expr)) { return false; - } else if (expr->getSubExpr()->getType()->isVoidPointerType()) { + } else if (expr->getSubExpr()->getType()->isVoidPointerType() && + expr->getType()->isPointerType()) { Convert(expr->getSubExpr()); PushConversionKind push(*this, ConversionKind::Unboxed); StrCat(std::format(".cast::<{}>().expect(\"ub:wrong type\")",