From 720975dff4d75ea913e83ee74abf64ade67bf142 Mon Sep 17 00:00:00 2001 From: jbrodman Date: Tue, 4 Feb 2014 03:36:19 -0800 Subject: [PATCH] Disallow initializing void * with ptr to const. --- expr.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/expr.cpp b/expr.cpp index 1b739a9a..b5c876fd 100644 --- a/expr.cpp +++ b/expr.cpp @@ -339,7 +339,14 @@ lDoTypeConv(const Type *fromType, const Type *toType, Expr **expr, return false; } else if (PointerType::IsVoidPointer(toPointerType)) { + if (fromPointerType->GetBaseType()->IsConstType()) { + if (!failureOk) + Error(pos, "Can't convert pointer to const \"%s\" to void pointer.", + fromPointerType->GetString().c_str()); + return false; + } // any pointer type can be converted to a void * + // ...almost. #731 goto typecast_ok; } else if (PointerType::IsVoidPointer(fromPointerType) &&