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

Ownership analysis may mark local mut as ref #163

Open
TheDan64 opened this issue Sep 24, 2019 · 1 comment
Open

Ownership analysis may mark local mut as ref #163

TheDan64 opened this issue Sep 24, 2019 · 1 comment
Labels
bug Something isn't working refactorer This issue relates to the refactoring tool

Comments

@TheDan64
Copy link
Contributor

#[no_mangle]
pub unsafe extern "C" fn mymemset(mut s: *mut wchar_t, mut c: wchar_t,
                                  n: size_t) {
    let mut i: size_t = 0;
    let mut p: *mut wchar_t = 0 as *mut wchar_t;
    p = s;
    i = 0i32 as size_t;
    while i < n { *p = c; p = p.offset(1isize); i = i.wrapping_add(1) }
    return;
}

p will be marked as "ref" by OA even though it gets assigned *p = c;

@TheDan64 TheDan64 added bug Something isn't working refactorer This issue relates to the refactoring tool labels Sep 24, 2019
@TheDan64
Copy link
Contributor Author

Possibly the same issue:

fn array_ref() {
    let mut q: [u32; 4] = [0; 4];

    #[nonnull]
    #[slice]
    let mut r = q.as_mut_ptr();

    *r.offset(0) = 1;
}

r isn't marked as mutable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working refactorer This issue relates to the refactoring tool
Projects
None yet
Development

No branches or pull requests

1 participant