-
Notifications
You must be signed in to change notification settings - Fork 349
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
Detect erroneous constants post-monomorphization #1382
Labels
A-interpreter
Area: affects the core interpreter
C-bug
Category: This is a bug.
I-false-UB
Impact: makes Miri falsely report UB, i.e., a false positive (with default settings)
I-ICE
Impact: makes Miri crash with some ICE
Comments
RalfJung
added
C-bug
Category: This is a bug.
A-interpreter
Area: affects the core interpreter
labels
May 1, 2020
Here is a testcase that currently ICEs: #![feature(const_panic)]
#![feature(never_type)]
#![warn(const_err)]
struct PrintName<T>(T);
impl<T> PrintName<T> {
const VOID: ! = panic!();
}
fn no_codegen<T>() {
let _ = PrintName::<T>::VOID;
}
fn main() {
no_codegen::<i32>();
} |
Even more interestingly, the same code is considered UB by Miri with
|
RalfJung
added
the
I-false-UB
Impact: makes Miri falsely report UB, i.e., a false positive (with default settings)
label
May 1, 2020
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This was referenced Aug 9, 2020
bors
added a commit
that referenced
this issue
Aug 10, 2020
accept some post-monomorphization errors Miri test for rust-lang/rust#75339. We also need to allow `ReferencedConstant` post-monomorphization errors. The other post-monomorphization errors should still be impossible to trigger in Miri. Fixes #1382.
bors
added a commit
that referenced
this issue
Aug 10, 2020
accept some post-monomorphization errors For #1382, we also need to allow `ReferencedConstant` post-monomorphization errors. The other post-monomorphization errors should still be impossible to trigger in Miri. The fix is not complete though without rust-lang/rust#75339.
Dylan-DPC-zz
pushed a commit
to Dylan-DPC-zz/rust
that referenced
this issue
Aug 10, 2020
evaluate required_consts when pushing stack frame in Miri engine [Just like codegen](https://github.com/rust-lang/rust/pull/70820/files#diff-32c57af5c8e23eb048f55d1e955e5cd5R194), Miri needs to make sure all `required_consts` evaluate successfully, to catch post-monomorphization errors. While at it I also moved the const_eval error reporting logic into rustc_mir::const_eval::error; there is no reason it should be in `rustc_middle`. I kept this in a separate commit for easier reviewing. Helps with rust-lang/miri#1382. I will add a test on the Miri side (done now: rust-lang/miri#1504). r? @oli-obk
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-interpreter
Area: affects the core interpreter
C-bug
Category: This is a bug.
I-false-UB
Impact: makes Miri falsely report UB, i.e., a false positive (with default settings)
I-ICE
Impact: makes Miri crash with some ICE
Codegen recently gained a loop to make sure that all constants required by the MIR actually error. Miri does not have anything like that yet, but we probably need that for soundness.
The text was updated successfully, but these errors were encountered: