Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AnyDevice and AnySurface possibly makes incorrect layout assumptions about trait objects #5080

Closed
udoprog opened this issue Jan 17, 2024 · 1 comment

Comments

@udoprog
Copy link
Contributor

udoprog commented Jan 17, 2024

Reference: rust-lang/reference#1448

Description

This and this cast assumes that the dst cast extracts the (thin) data pointer.

*pointer*
*vtable*

Which while it should mostly match up in practice, is to my knowledge not currently guaranteed by Rust. A different compiler option or future compilers could legally opt to re-order or change the semantics of this behavior.

I have a branch which re-implements these using internal vtables, while also removing HalSurface. I'll be happy to clean it up into a PR once this has been triaged.

@udoprog
Copy link
Contributor Author

udoprog commented Jan 17, 2024

Note that ptr-meta is an unstable feature which provides APIs for decomposing wide pointers, but it is not yet stable nor can I find the proposed casting logic having been accepted into a stable compiler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants