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

could not evaluate static initializer #65526

Closed
Mark-Simulacrum opened this issue Oct 17, 2019 · 7 comments
Closed

could not evaluate static initializer #65526

Mark-Simulacrum opened this issue Oct 17, 2019 · 7 comments
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Mark-Simulacrum
Copy link
Member

https://crater-reports.s3.amazonaws.com/beta-1.39-1/beta-2019-09-28/reg/vptr-0.2.0/log.txt
looks like this is inside a proc macro so would be good to figure out what the raw expression is

cc #64962

@Mark-Simulacrum Mark-Simulacrum added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-const-eval Area: Constant evaluation (MIR interpretation) E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Oct 17, 2019
@Mark-Simulacrum Mark-Simulacrum added this to the 1.39 milestone Oct 17, 2019
@Mark-Simulacrum Mark-Simulacrum added the regression-from-stable-to-beta Performance or correctness regression from stable to beta. label Oct 17, 2019
@Centril
Copy link
Contributor

Centril commented Oct 17, 2019

cc @oli-obk @RalfJung -- my guess is the crate is doing something UB in the static.

@ecstatic-morse
Copy link
Contributor

ecstatic-morse commented Oct 17, 2019

This proc macro creates a reference to address 0 here. It should switch to memoffset, whose behavior is not as undefined 😄.

@Centril
Copy link
Contributor

Centril commented Oct 17, 2019

cc @ogoffart

Closing as wontfix because of UB.

@Centril Centril closed this as completed Oct 17, 2019
@RalfJung
Copy link
Member

Well, there's no way to do offsetof in CTFE right now. Previously, there were some approaches that seemed to work but actually were UB, like this one. But now our const-time UB checker got a bit better, hence the crater regression.

#63810 is the key ingredient to enable a less insane version of offsetof in CTFE. (Basically, the CTFE variant is then just as unsound as memoffset. In other words, it is UB but works in practice because right now we do not exploit that UB in the compiler.)

@RalfJung
Copy link
Member

I opened an issue in the crate to give the author a heads-up: ogoffart/vptr#1.

@Mark-Simulacrum were there other regressions that look similar? offsetof is one of these notorious operations that Rust doesn't support but people want it, and they want it so badly that instead of making the language support offsetof they write programs with UB that happen to work at the time of implementation... so I'd not be surprised to see that kind of snippet come up a few times.

@Mark-Simulacrum
Copy link
Member Author

I didn't see any other cases of this.

@ecstatic-morse
Copy link
Contributor

Ugh, I missed the static declaration.

@Centril Centril removed this from the 1.39 milestone Nov 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants