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

Transmuting self to mut self is UB #3

Closed
kpp opened this issue Mar 20, 2019 · 1 comment
Closed

Transmuting self to mut self is UB #3

kpp opened this issue Mar 20, 2019 · 1 comment

Comments

@kpp
Copy link

kpp commented Mar 20, 2019

let mut_self:&mut Self = unsafe { transmute(self) };

let ppu:&mut Ppu = unsafe { &mut *self.ppu };

let mut_self:&mut Self = unsafe { transmute(self) };

let mut_self:&mut Self = unsafe { transmute(self) };

@MichaelBurge
Copy link
Owner

Thanks for catching this. I've replaced these with a Cell in the Joystick struct

110fa57

That particular line in ppu.rs is okay, because CpuPpuInterconnect stores mutable pointers which that is turning into mutable references.

There is a related issue in that

let cpu = unsafe { &mut *self.cpu };

allows two mutable references to a C6502 object to be live at the same time. But that is slightly different than what you have here.

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