-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Fix ICE on offsetted ZST pointer #147576
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
base: master
Are you sure you want to change the base?
Fix ICE on offsetted ZST pointer #147576
Conversation
As far as I can tell, this was buggy between 1.39 (RUST-63635) and 1.42 (RUST-67000), and I probably copied the earlier code when performing this optimization again in RUST-123936. A grep for `const_usize.*align` found the same code copied to rustc_codegen_gcc but I don't see other cases where we get this wrong.
Some changes occurred in compiler/rustc_codegen_gcc Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 |
r? @nnethercote rustbot has assigned @nnethercote. Use |
The job Click to see the possible cause of the failure (guessed by this bot)
|
const A: *const () = (&() as *const ()).wrapping_byte_add(2); | ||
const B: *const () = (&Foo as *const _ as *const ()).wrapping_byte_add(2); | ||
const C: *const () = (&Foo as *const _ as *const ()).wrapping_byte_add(usize::MAX); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this at all. Can you explain a little? Perhaps this test needs an explanatory comment at the top?
I'm not sure this is the right fix, but it's simple enough and does roughly what I'd expect. Like with the previous optimization to codegen usize rather than a zero-sized static, there's no guarantee that we continue returning a particular value from the offsetting.
A grep for
const_usize.*align
found the same code copied to rustc_codegen_gcc and cranelift but a quick skim didn't find other cases of similar 'optimization'. That said, I'm not convinced I caught everything, it's not trivial to search for this.Closes #147516