[clang] [clang][bytecode] Fix emitting dtors of zero-sized arrays (PR #134672)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 8 09:29:24 PDT 2025


================
@@ -6818,15 +6818,17 @@ bool Compiler<Emitter>::emitDestruction(const Descriptor *Desc,
         return true;
     }
 
-    for (ssize_t I = Desc->getNumElems() - 1; I >= 0; --I) {
-      if (!this->emitConstUint64(I, Loc))
-        return false;
-      if (!this->emitArrayElemPtrUint64(Loc))
-        return false;
-      if (!this->emitDestruction(ElemDesc, Loc))
-        return false;
-      if (!this->emitPopPtr(Loc))
-        return false;
+    if (size_t N = Desc->getNumElems()) {
----------------
efriedma-quic wrote:

Please try to avoid implicit integer conversions where overflow is a potential issue; `Desc->getNumElems()` returns an `unsigned`, so please just make the variable unsigned as well.

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


More information about the cfe-commits mailing list