# \[Pitch\] Cell, ConstCell, and Volatile

**URL:** <https://forums.swift.org/t/pitch-cell-constcell-and-volatile/89582>\
**Category:** Pitches\
**Created:** [September 15, 2026, 7:18pm UTC](https://forums.swift.org/t/pitch-cell-constcell-and-volatile/89582 "2026-09-15T19:18:08Z")\
**Posts on this page:** 1\
**Showing post:** 23

<div class="post-metadata">

**Author:** ![Alejandro](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/alejandro/32/46197_2.png) [@Alejandro](https://forums.swift.org/u/Alejandro)\
**Post date:** [September 29, 2026, 9:09pm UTC](https://forums.swift.org/t/pitch-cell-constcell-and-volatile/89582/23 "2026-09-29T21:09:09Z")

</div>

> [@sebastian-vohn](#):
>
> In addition to enabling interior mutability, the existing `_Cell` type in the standard library guarantees [address stability](https://forums.swift.org/t/implementation-details-of-new-mutex-type/71942/5) until the value (or rather, an owning binding of that value) is consumed. Having stable addresses is important for certain C interoperability scenarios, where a called C function (temporarily) escapes a passed pointer out of its body; for instance, if a C function registers an event callback with the pointer as context argument.
> 
> Will the pitched `Cell` and `ConstCell` types guarantee address stability like `_Cell` does today? That is, can the pointer passed to the `body` of their `withUnsafe{…}Pointer` methods be safely escaped and used until the original owning binding of the cell is consumed? In that case, would it make sense to directly expose the pointer as a property, similar to `_Cell`, since escaping a pointer from a with-style closure is normally an unsafe anti-pattern?

`Cell` guarantees address stability _while under any read/write accesses_. So calling a method like `withUnsafeMutablePointer` guarantees the address stability from the start of the method call until the end of the call. `Cell` itself can still be moved just like any other noncopyable type. The same is true for `Mutex`, it can still be moved! It's just that places where you'd typically use it prevent it from being moved i.e. globals, class ivars, etc.

There is a slight caveat to this too though because nesting a `Cell` in another type gives it that same guarantee which presents the following scenario:

```swift
struct Nested: ~Copyable {
  let x: Cell<Int>

  func something() {
    // This is technically ok because 'Nested' is
    // guaranteed to have a stable address, to which
    // 'x' is a part of, until 'something'
    // has finished.
    let ptr = x.withUMP { $0 }
  }
}

```

but the following would not be ok:

```swift
func foo() {
  let x = Cell(123)

  // NOT OK; DANGER
  // 'x' can be moved!
  let ptr = x.withUMP { $0 }
}

```

---

_[View the full topic](https://forums.swift.org/t/pitch-cell-constcell-and-volatile/89582)._
