diff --git a/mlir/lib/IR/OperationSupport.cpp b/mlir/lib/IR/OperationSupport.cpp index c60e0566514285..fc7cf9310a837d 100644 --- a/mlir/lib/IR/OperationSupport.cpp +++ b/mlir/lib/IR/OperationSupport.cpp @@ -237,7 +237,9 @@ detail::OperandStorage::~OperandStorage() { if (isDynamicStorage()) { TrailingOperandStorage &storage = getDynamicStorage(); storage.~TrailingOperandStorage(); - free(&storage); + // Workaround false positive in -Wfree-nonheap-object + auto *mem = &storage; + free(mem); } else { getInlineStorage().~TrailingOperandStorage(); } @@ -371,8 +373,11 @@ MutableArrayRef detail::OperandStorage::resize(Operation *owner, new (&newOperands[numOperands]) OpOperand(owner); // If the current storage is also dynamic, free it. - if (isDynamicStorage()) - free(&storage); + if (isDynamicStorage()) { + // Workaround false positive in -Wfree-nonheap-object + auto *mem = &storage; + free(mem); + } // Update the storage representation to use the new dynamic storage. representation = reinterpret_cast(newStorage);