Closed
Description
I was playing around with some code and found a condition that should result in a compilation error but results in a crash instead.
This code compiles normally:
const LENGTH: usize = 4;
struct Thing {
f: [[f64; 2]; LENGTH],
}
fn main() {
let t = Thing { f: [[0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]] };
}
If you change const LENGTH: usize = 4;
to const LENGTH: u32 = 4;
you get a compilation error, as expected.
However, if you change it to const LENGTH: f64 = 4;
you get a crash.
Meta
rustc 1.15.1 (021bd294c 2017-02-08)
binary: rustc
commit-hash: 021bd294c039bd54aa5c4aa85bcdffb0d24bc892
commit-date: 2017-02-08
host: x86_64-pc-windows-msvc
release: 1.15.1
LLVM version: 3.9
Backtrace:
thread 'rustc' panicked at 'Box<Any>', C:\bot\slave\stable-dist-rustc-win-msvc-64\build\src\librustc_errors\lib.rs:423
stack backtrace:
0: 0x7ffa5edfedea - std::panicking::Location::line::h77e1a07e4d6d891a
1: 0x7ffa5edfe274 - std::panicking::Location::line::h77e1a07e4d6d891a
2: 0x7ffa5ee01ccd - std::panicking::rust_panic_with_hook::h537b769c8e0e1c2d
3: 0x7ffa50452a1a - <unknown>
4: 0x7ffa5046d59e - rustc_errors::Handler::bug::had89a2eafd9d44ba
5: 0x7ffa27149fc5 - rustc::session::bug_fmt::hc10f935d6ba6cd93
6: 0x7ffa27149df2 - rustc::session::bug_fmt::hc10f935d6ba6cd93
7: 0x7ffa2714950c - rustc::session::bug_fmt::hc10f935d6ba6cd93
8: 0x7ffa4f69453b - rustc_const_eval::eval::eval_const_expr_partial::h8506b167c7a43499
9: 0x7ffa4f68b0be - rustc_const_eval::eval::eval_const_expr_partial::h8506b167c7a43499
10: 0x7ffa4f68e053 - rustc_const_eval::eval::eval_const_expr_partial::h8506b167c7a43499
11: 0x7ffa4f695153 - rustc_const_eval::eval::eval_length::h4e0736539c568f4d
12: 0x7ffa43472646 - <rustc_typeck::astconv::AstConv<'gcx, 'tcx> + 'o>::ast_ty_to_ty::h39a0321307d078df
13: 0x7ffa434814f8 - <rustc::hir::Generics as rustc_typeck::collect::GetTypeParameterBounds<'tcx>>::get_type_parameter_bounds::h82c8b3f9d32e8939
14: 0x7ffa4347875f - <rustc_typeck::collect::CollectItemTypesVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item::h07d02b3adc3c96ed
15: 0x7ffa43477ea5 - rustc_typeck::collect::collect_item_types::h287fdae2e3e8d768
16: 0x7ffa434aa4d4 - rustc_typeck::check_crate::h3d799501ecb83cfd
17: 0x7ffa5f0bdb4e - rustc_driver::driver::count_nodes::hd8d06c8fe5cb012d
18: 0x7ffa5f02502f - <unknown>
19: 0x7ffa5f0a8b52 - rustc_driver::driver::compile_input::h4d6139b5511c2803
20: 0x7ffa5f0f94e7 - rustc_driver::run_compiler::hc652dda834d2f45c
21: 0x7ffa5efddd6e - <unknown>
22: 0x7ffa5ee04681 - _rust_maybe_catch_panic
23: 0x7ffa5f006904 - <unknown>
24: 0x7ffa5edfc3ae - std::sys::imp::thread::Thread::new::hcb2a817bb8ef6963
25: 0x7ffa67e38363 - BaseThreadInitThunk