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

dereferences in statics can create broken code #28324

Closed
arielb1 opened this issue Sep 9, 2015 · 4 comments
Closed

dereferences in statics can create broken code #28324

arielb1 opened this issue Sep 9, 2015 · 4 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@arielb1
Copy link
Contributor

arielb1 commented Sep 9, 2015

STR

extern {
    static error_message_count: u32; // anything will do
}
pub static BAZ: u32 = *&error_message_count;
fn main() {}

@arielb1
Copy link
Contributor Author

arielb1 commented Sep 9, 2015

Result

This code can't be linked. Currently it trips an LLVM assertion.

@eefriedman
Copy link
Contributor

I think this is a duplicate... but I can't find it at the moment; essentially, we don't enforce the restriction that you're not allowed to dereference the address of a static.

@alexispurslane
Copy link
Contributor

Should this restriction be added?

@steveklabnik steveklabnik added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Sep 28, 2015
@jonas-schievink
Copy link
Contributor

This seems to segfault on stable and beta. On nightly it doesn't compile, so this looks fixed: error: cannot refer to other statics by value, use the address-of operator or a constant instead

@arielb1 arielb1 added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jun 10, 2016
sophiajt pushed a commit to sophiajt/rust that referenced this issue Aug 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

5 participants