================
@@ -947,6 +947,12 @@ std::optional<APValue> Pointer::toRValue(const Context 
&Ctx,
 
   // Just load primitive types.
   if (OptPrimType T = Ctx.classify(ResultType)) {
+    // Check if the pointer descriptor's primitive type matches what we're
+    // trying to read. This fails when we reinterpret_cast a pointer to a
+    // different type (e.g. *(int**)"").
+    if (const Descriptor *D = getFieldDesc();
+        (D->isPrimitive() || D->isPrimitiveArray()) && D->getPrimType() != *T)
+      return std::nullopt;
----------------
tbaederr wrote:

```suggestion
    if (const Descriptor *D = getFieldDesc();
        (D->isPrimitive() || D->isPrimitiveArray()) && D->getPrimType() != *T)
      return std::nullopt;
```

https://github.com/llvm/llvm-project/pull/179030
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to