-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Compiling with -C debuginfo=2
reduces warnings unexpectedly
#48900
Comments
By the way, this must have existed for quite some time, because the second version of the Book does something similar without a warning from |
I can't reproduce this on 1.26.0 — are you able to check it still occurs on nightly? |
Definitely present on % rustup show
Default host: x86_64-unknown-linux-gnu
installed toolchains
--------------------
stable-x86_64-unknown-linux-gnu
nightly-2017-12-21-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu (default)
active toolchain
----------------
nightly-x86_64-unknown-linux-gnu (default)
rustc 1.26.0-nightly (2789b067d 2018-03-06)
% cat src/main.rs
fn main() {
let a = [1, 2, 3];
let index = 10;
let element = a[index];
println!("element is {}", element);
}
% rustc src/main.rs -C debuginfo=2
% rustc src/main.rs -C debuginfo=1
warning: this expression will panic at run-time
--> src/main.rs:4:19
|
4 | let element = a[index];
| ^^^^^^^^ index out of bounds: the len is 3 but the index is 10
|
Ah, interesting: it occurs for your test program, but not for this one (i.e. here the warning is always displayed): fn main() {
let a: [i32; 1] = [0; 1];
a[1];
} |
Afraid I'm new to rust - is that a type annotation that |
|
Just from a little looking around, the check here seems to be the cause: rust/src/librustc_trans/mir/mod.rs Lines 266 to 281 in c90f682
If dbg == false (i.e. debuginfo != 2 ), then the first return is hit and everything works. Otherwise, the returned value is constructed differently (LocalRef::Place(place) ) and the warnings henceforth do not appear.
|
My suspicion is that this issue is specific to the old constant evaluation system, which has recently been completely replaced by miri. It's hard to be completely sure, because the array indexing warning has not yet been implemented in miri, but it seems very likely. Have you spotted any other kinds of warnings that also disappear for |
Passing
-C debuginfo=2
torustc
gives fewer warnings thandebuginfo={0,1}
. I expected to see the same output regardless of debug symbols.Example
Version
The text was updated successfully, but these errors were encountered: