[flang-commits] [flang] [flang][runtime] Interoperable POINTER deallocation validation (PR #96100)

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Mon Jun 24 20:38:07 PDT 2024


================
@@ -124,6 +124,23 @@ void RTDEF(PointerAssociateRemapping)(Descriptor &pointer,
   }
 }
 
+RT_API_ATTRS void *AllocateValidatedPointerPayload(std::size_t byteSize) {
+  // Add space for a footer to validate during deallocation.
+  constexpr std::size_t align{sizeof(std::uintptr_t)};
+  byteSize = ((byteSize / align) + 1) * align;
----------------
vzakhari wrote:

Can you explain why?  If `byteSize` is initially zero, the total allocation will end up being `2 * align` - isn't `align` bytes allocation enough?

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


More information about the flang-commits mailing list