Skip to content

Compiler intelligence: Pointers to comptime data should not be accessible at runtime #5874

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
ghost opened this issue Jul 15, 2020 · 2 comments

Comments

@ghost
Copy link

ghost commented Jul 15, 2020

This means, in the ideal case, the following code should not compile:

pub fn testing123() void {
    comptime var value: u32 = 3;
    const pointer = &value;
    var bad = pointer; // this is an undefined address
}

To detect this, we'd either need to make sure that the value of pointer never gets passed to codegen (ideal, hard), or that pointer reads as null in codegen (good enough, easy).

@Vexu
Copy link
Member

Vexu commented Jul 15, 2020

Should be covered by #1487, #2710 and #3996.

@ghost
Copy link
Author

ghost commented Jul 15, 2020

Not quite -- the issue may be the same, but the proposed solution is different.

This issue was closed.
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