[clang] [clang][bytecode] Fix stack corruption in pointer arithmetic discard (PR #176555)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 28 08:35:10 PST 2026


================
@@ -1083,21 +1083,21 @@ bool Compiler<Emitter>::VisitPointerArithBinOp(const BinaryOperator *E) {
   if (Op == BO_Add) {
     if (!this->emitAddOffset(OffsetType, E))
       return false;
-
-    if (classifyPrim(E) != PT_Ptr)
-      return this->emitDecayPtr(PT_Ptr, classifyPrim(E), E);
-    return true;
-  }
-  if (Op == BO_Sub) {
+  } else if (Op == BO_Sub) {
     if (!this->emitSubOffset(OffsetType, E))
       return false;
+  } else {
+    return false;
+  }
 
----------------
Serosh-commits wrote:

> is it worth changing this to a switch? Not because there are many options but because it makes it structurally clearer that this is an either/or case?
yes it would be better changed it thanks 

https://github.com/llvm/llvm-project/pull/176555


More information about the cfe-commits mailing list