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

Pool.inner_mut() and other mut methods are UB #2

Closed
seanmonstar opened this issue Apr 11, 2015 · 3 comments
Closed

Pool.inner_mut() and other mut methods are UB #2

seanmonstar opened this issue Apr 11, 2015 · 3 comments

Comments

@seanmonstar
Copy link

According to this doc page http://doc.rust-lang.org/1.0.0-beta/std/cell/struct.UnsafeCell.html, transmuting &T to &mut T is undefined behavior. I believe rustc tells llvm they are readonly unless the unsafe lang item is used, which is UnsafeCell.

@carllerche
Copy link
Owner

Hmmm.... so what about transmuting *mut T -> &mut T, is that permitted? Should PoolInner be wrapped in an UnsafeCell?

@seanmonstar
Copy link
Author

I do not know if that's safe. However, you can easily do let a = &mut *ptr; to get &mut T from a *mut T.

@seanmonstar
Copy link
Author

Finally filed that PR for a lint as well: rust-lang/rust#24392

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