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

(c2rust-analyze) Support genericity over KnownFn ptr perms #1006

Open
kkysen opened this issue Jul 26, 2023 · 0 comments
Open

(c2rust-analyze) Support genericity over KnownFn ptr perms #1006

kkysen opened this issue Jul 26, 2023 · 0 comments

Comments

@kkysen
Copy link
Contributor

kkysen commented Jul 26, 2023

For KnownFns like

fn strchr(
    // `WRITE` because the return type is derived from `cs`'s provenance.
    cs: *const c_char: [READ | WRITE | OFFSET_ADD | NON_NULL],
    c: c_int,
) -> *mut c_char: [READ | WRITE | OFFSET_ADD];

it would be nice for them to pass through certain permissions like we do for ptr::offset (a builtin for us). If the returned pointer is never written, there's no need to require WRITE on the argument. In other words, we'd like to be able to be generic over certain permissions, like how fn foo and fn foo_mut functions are meant to be.

Supporting this is still a ways away and not very high-priority, but I imagine we could try to implement this either by allowing permissions to be generic or to allow multiple declarations of the same fn with different permissions (like how fn foo and fn foo_mut do it) and then selecting the KnownFn with the matching permissions.

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