Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upDrop flags on the stack not reinitialized in loops #27401
Comments
alexcrichton
added
I-nominated
T-compiler
labels
Jul 30, 2015
pnkfelix
self-assigned this
Jul 30, 2015
This comment has been minimized.
This comment has been minimized.
|
Interestingly this slight variation on the above code does drop twice as expected: struct A<'a>(&'a mut i32);
impl<'a> Drop for A<'a> {
fn drop(&mut self) {
*self.0 += 1;
}
}
fn main() {
let mut cnt = 0;
for i in 0..2 {
let a; a = A(&mut cnt); // This was `let a = A(&mut cnt);` before
if i == 1 {
break
}
drop(a);
}
assert_eq!(cnt, 2);
} |
pnkfelix
added a commit
to pnkfelix/rust
that referenced
this issue
Jul 31, 2015
pnkfelix
added a commit
to pnkfelix/rust
that referenced
this issue
Jul 31, 2015
pnkfelix
referenced this issue
Jul 31, 2015
Closed
Reinitialize the dropflag hint in bindings #27413
bors
added a commit
that referenced
this issue
Jul 31, 2015
bors
added a commit
that referenced
this issue
Jul 31, 2015
pnkfelix
added a commit
to pnkfelix/rust
that referenced
this issue
Aug 7, 2015
bors
added a commit
that referenced
this issue
Aug 7, 2015
bors
added a commit
that referenced
this issue
Aug 7, 2015
bors
closed this
in
#27582
Aug 7, 2015
brson
added a commit
to brson/rust
that referenced
this issue
Aug 10, 2015
sfackler
added a commit
to sfackler/rust
that referenced
this issue
Aug 11, 2015
pnkfelix
added a commit
to pnkfelix/rust
that referenced
this issue
Aug 19, 2015
pnkfelix
added a commit
to pnkfelix/rust
that referenced
this issue
Aug 19, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
alexcrichton commentedJul 30, 2015
It looks like that when a local variable is initialized in a loop and dropped in the same loop, the stack local drop flag for that local isn't reinitialized to "not dropped" when the loop runs after the first time.
Concretely, this test passes on stable and fails on nightly right now:
cc @pnkfelix