From 1d63da8379fd91540b5d25a030a8aa1ae592b3cf Mon Sep 17 00:00:00 2001 From: Stephen Canon Date: Thu, 23 Oct 2025 20:16:23 -0400 Subject: [PATCH 1/2] Attempt to clarify the deallocation rules for UMBP. --- stdlib/public/core/UnsafePointer.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stdlib/public/core/UnsafePointer.swift b/stdlib/public/core/UnsafePointer.swift index a4e8b9558b9f1..8eda73f0a024b 100644 --- a/stdlib/public/core/UnsafePointer.swift +++ b/stdlib/public/core/UnsafePointer.swift @@ -788,6 +788,10 @@ extension UnsafeMutablePointer where Pointee: ~Copyable { /// /// intPointer.deallocate() /// + /// You should only use `deallocate()` to end the lifetime of memory + /// created with `allocate()`; it is a programming error to use `free` or + /// another deallocation API, and may result in undefined behavior. + /// /// - Parameter count: The amount of memory to allocate, counted in instances /// of `Pointee`. @inlinable From a788c13bae19ff3c813aab6cb016946361bc4f6b Mon Sep 17 00:00:00 2001 From: Stephen Canon Date: Thu, 23 Oct 2025 21:13:26 -0400 Subject: [PATCH 2/2] Update stdlib/public/core/UnsafePointer.swift Co-authored-by: Guillaume Lessard --- stdlib/public/core/UnsafePointer.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/public/core/UnsafePointer.swift b/stdlib/public/core/UnsafePointer.swift index 8eda73f0a024b..f16ca4016cf40 100644 --- a/stdlib/public/core/UnsafePointer.swift +++ b/stdlib/public/core/UnsafePointer.swift @@ -788,7 +788,7 @@ extension UnsafeMutablePointer where Pointee: ~Copyable { /// /// intPointer.deallocate() /// - /// You should only use `deallocate()` to end the lifetime of memory + /// You must only use `deallocate()` to end the lifetime of memory /// created with `allocate()`; it is a programming error to use `free` or /// another deallocation API, and may result in undefined behavior. ///