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

A slice marked with @(rodata) can still be modified (and won't throw an error) #3964

Closed
kranasAngel opened this issue Jul 23, 2024 · 0 comments

Comments

@kranasAngel
Copy link

kranasAngel commented Jul 23, 2024

Context

  • Operating System & Odin Version: MacOs Sonoma odin version dev-2024-07:d912c6e32

Expected Behavior

We expect X to be unmodifiable (and panic with an error) however, instead the underlying data of the slice is corrupted.

Current Behavior

Similar to an array marked with @(rodata), we expect to panic

Steps to Reproduce

@(rodata)
m_nums := []int{2,5,6};

ret_m_slice :: proc() -> []int {
    return m_nums;
}

main :: proc() {
    x := ret_m_slice();
    y := 1;
    x[y] = 7;
    fmt.println(x);
    fmt.println(ret_m_slice());
}

shell output

odin build temp && ./temp.bin                                                                                                  
[2, 7, 6]                                                                                                                                                              
[2, 7, 6]                              
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

1 participant