You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using "mem::unitialized()" can lead to "Attempted to instantiate uninhabited type" #139
thread 'main' panicked at 'Attempted to instantiate uninhabited type [main::Void; 8]', /rustc/ceb2512144d1fc26330e85fb9d41c22ba1866259/src/libcore/mem.rs:630:5
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
1: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:70
2: std::panicking::default_hook::{{closure}}
at src/libstd/sys_common/backtrace.rs:58
at src/libstd/panicking.rs:200
3: std::panicking::default_hook
at src/libstd/panicking.rs:215
4: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:478
5: std::panicking::continue_panic_fmt
at src/libstd/panicking.rs:385
6: rust_begin_unwind
at src/libstd/panicking.rs:312
7: core::panicking::panic_fmt
at src/libcore/panicking.rs:85
8: core::panicking::panic
at src/libcore/panicking.rs:49
9: core::mem::uninitialized
at /rustc/ceb2512144d1fc26330e85fb9d41c22ba1866259/src/libcore/mem.rs:630
10: <smallvec::SmallVec<A>>::new
at /home/pierre/.cargo/registry/src/github.life-white.uk-1ecc6299db9ec823/smallvec-0.6.8/lib.rs:402
11: playpen::main
at src/main.rs:3
12: std::rt::lang_start::{{closure}}
at /rustc/ceb2512144d1fc26330e85fb9d41c22ba1866259/src/libstd/rt.rs:64
13: std::panicking::try::do_call
at src/libstd/rt.rs:49
at src/libstd/panicking.rs:297
14: __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:92
15: std::rt::lang_start_internal
at src/libstd/panicking.rs:276
at src/libstd/panic.rs:388
at src/libstd/rt.rs:48
16: std::rt::lang_start
at /rustc/ceb2512144d1fc26330e85fb9d41c22ba1866259/src/libstd/rt.rs:64
17: main
18: __libc_start_main
19: _start
"Why would someone create a SmallVec of Void?" you may ask.
In my situation, the type (Void here) is a template parameter of one of my structs.
When the user uses a Void, the SmallVec will of course always remain empty. However creating an empty SmallVec shouldn't itself lead to a panic.
Activity
nox commentedon Feb 1, 2019
Relevant (IIRC): #126
RalfJung commentedon May 5, 2019
This also shows that e.g.
smallvec::SmallVec::<[bool; 8]>::new()causes UB -- it creates aboolthat is not properly initialized.Once rust-lang/rust#60445 lands, the
ManuallyDrophere should be replaced byMaybeUninit. That should help with these cases.Add a test for #139.
Auto merge of #170 - servo:test-139, r=SimonSapin
Add a test for servo#139.
Add a test for servo#139.
Add a test for servo#139.
Add a test for servo#139.