reference icon indicating copy to clipboard operation
reference copied to clipboard

[undefined.validity.union] dyn Trait raw pointer is subject to debate.. where's the debate?

Open fasterthanlime opened this issue 5 months ago • 3 comments

under undefined.validity.union:

dyn Trait metadata must be a pointer to a compiler-generated vtable for Trait (For raw pointers, this requirement remains a subject of some debate.)

which debate? where? how? I'd like to read more.

fasterthanlime avatar Sep 24 '25 13:09 fasterthanlime

https://github.com/rust-lang/unsafe-code-guidelines/issues/516

ia0 avatar Sep 24 '25 13:09 ia0

Here's a possible source: https://github.com/rust-lang/rust/issues/101336

fasterthanlime avatar Sep 24 '25 13:09 fasterthanlime

There's been discussion about *const dyn Trait ~and whether it can have an invalid vtable pointer for pointer metadata stabilization~: https://github.com/rust-lang/rust/issues/81513

Oop, apparently in 2024 they decided that *const dyn Trait needed to have a valid vtable (which I personally disagree with - now it's impossible to have a null *const T for all T: ?Sized)

kupiakos avatar Sep 24 '25 18:09 kupiakos