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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug][compiler-v2] Reference safety has different behavior when mut refs and inline functions are involved #13177

Open
vineethk opened this issue May 2, 2024 · 0 comments
Labels
bug Something isn't working compiler-v2-stable compiler-v2 stale-exempt Prevents issues from being automatically marked and closed as stale

Comments

@vineethk
Copy link
Contributor

vineethk commented May 2, 2024

馃悰 Bug

Consider the following Move program:

module 0xc0ffee::m {
    inline fun inc(x: &mut u64): u64 {
        *x = *x + 1;
        *x
    }

    fun add(x: u64, y: u64): u64 {
        x + y
    }

    public fun test(): u64 {
        let x = 1;
        x + inc(&mut x) + inc(&mut x)
    }
}

When it is compiled with v1, we get a reference safety error ("invalid operation, could create dangling a reference"). When compiled with v2, there is no compiler error or runtime error.

Because this is a divergent behavior between the compiler, I am opening an issue to track it; we may decide this is not an actual bug, but that v2 just accepts more (safe) programs than v1.

@vineethk vineethk added bug Something isn't working compiler-v2 labels May 2, 2024
@sausagee sausagee added the stale-exempt Prevents issues from being automatically marked and closed as stale label May 20, 2024
@wrwg wrwg removed their assignment May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler-v2-stable compiler-v2 stale-exempt Prevents issues from being automatically marked and closed as stale
Projects
Status: Assigned
Development

No branches or pull requests

3 participants