You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fn foo(x: option<~int>, b: bool) -> int {
match x {
none => { 1 }
some(copy x) if b => { *x }
some(_) => { 0 }
}
}
fn main() {
foo(some(~22), true);
foo(some(~22), false);
foo(none, true);
foo(none, false);
}
the reason is that copy bindings (currently, anyhow) create a temporary that is only used in the guard, copy into it, and then free it on exit from the match. But this temporary is never initialized. If you wind up in an arm that doesn't use the temporary, then, you try to free uninitialized data. Bad.
It would be better for copy bindings to perform the copy, test the guard, then free the data if the guard is false---but reuse the data if the guard is true. I'm going to see how much surgery that would be.
Or maybe copy bindings and guards should just be incompatible?
The text was updated successfully, but these errors were encountered:
Update Rust toolchain from nightly-2024-06-23 to nightly-2024-06-24
without any other source changes.
This is an automatically generated pull request. If any of the CI checks
fail, manual intervention is required. In such a case, review the
changes at https://github.com/rust-lang/rust from
rust-lang@3cb521a
up to
rust-lang@bcf94de.
This test segfaults:
the reason is that copy bindings (currently, anyhow) create a temporary that is only used in the guard, copy into it, and then free it on exit from the match. But this temporary is never initialized. If you wind up in an arm that doesn't use the temporary, then, you try to free uninitialized data. Bad.
It would be better for copy bindings to perform the copy, test the guard, then free the data if the guard is false---but reuse the data if the guard is true. I'm going to see how much surgery that would be.
Or maybe copy bindings and guards should just be incompatible?
The text was updated successfully, but these errors were encountered: