-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Some objects get zeroed when copied from, affecting original object #22536
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
Comments
Also see the workaround by @csherratt in PistonDevelopers/gfx_graphics#136 |
I managed to extract and simplify the case: trait Resources {
type Buffer: Copy;
}
struct BufferHandle<R: Resources> {
raw: <R as Resources>::Buffer,
}
impl<R: Resources> Copy for BufferHandle<R> {}
#[derive(Copy)]
enum Res {}
impl Resources for Res {
type Buffer = u32;
}
fn main() {
let b: BufferHandle<Res> = BufferHandle { raw: 1 };
let c = b;
print!("{}{}", c.raw, b.raw);
} Prints: |
cc @nikomatsakis, @pnkfelix, looks like an associated type bug. Thanks @kvark for the reduction! Also nominating. |
Will investigate. |
And yes, thanks @kvark ! |
|
I'm sorry, is there any progress on this one? We are considering switching everything to |
This is the only bug that blocks Piston at the moment, but it does across several projects. Is there a way I can help? |
@kvark @bvssvni No progress yet, but @pnkfelix and @nikomatsakis will solve it soon, I just know it! |
@pnkfelix You are awesome! |
P-backcompat-lang, 1.0 |
…sakis Ensure we do not zero when \"moving\" types that are Copy. Uses more precise `type_needs_drop` for deciding about emitting cleanup code. Added notes about the weaknesses regarding `ty::type_contents` here. Fix rust-lang#22536
From gfx-rs/gfx#574
In Gfx, something happens when
*buffer
(BufferHandle) is called, which zeroes whole or parts of the original object.This might be a compiler bug.
cc @csherratt @kvark
The text was updated successfully, but these errors were encountered: