Skip to content

[Rejects-valid] with two-phase-borrows #46764

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

Closed
leonardo-m opened this issue Dec 16, 2017 · 1 comment
Closed

[Rejects-valid] with two-phase-borrows #46764

leonardo-m opened this issue Dec 16, 2017 · 1 comment

Comments

@leonardo-m
Copy link

A little example code:

#![feature(asm)]

#[allow(unused_variables, unused_mut, unused_assignments)]
fn foo(a: u64, b: u64, x: u64) -> u64 {
    let mut w: u64;
    let mut result: u64;

    unsafe {
        asm!("mulq $3; divq $4;"
             : "=&{ax}"(w), "=&{dx}"(result)
             : "{ax}"(a), "r"(b), "r"(x)
             );
    }
    result
}

fn main() {
    foo(1, 2, 3);
}

Compiles and runs with no arguments:

...>rustc test.rs

But gives an error with two-phase-borrows:

...>rustc -Z borrowck=mir -Z two-phase-borrows test.rs
error[E0381]: use of possibly uninitialized variable: `result`
  --> test.rs:14:5
   |
14 |     result
   |     ^^^^^^ use of possibly uninitialized `result`
rustc 1.24.0-nightly (77efd6800 2017-12-15)
host: x86_64-pc-windows-gnu
@arielb1
Copy link
Contributor

arielb1 commented Dec 17, 2017

Duplicate of #45695 - ASM statements are broken in moveck & MIR borrowck.

@arielb1 arielb1 closed this as completed Dec 17, 2017
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