Skip to content

buggy code generated when initializing a [Vec<_>;..] #27484

Closed
@steven807

Description

@steven807

The following code non-deterministically either works, goes into an infinite loop, or seg-faults, on both my mac environment and on https://play.rust-lang.org/, in all three channels. However, only in Debug mode -- it works fine in all three cases in Release. It also works fine if the "uninitialized()" is replaced by "zeroed()".

use std::mem;

fn main() {
    let _:[Vec<i32>;2] = {
        let mut arr: [Vec<i32>; 2] = unsafe { mem::uninitialized() };
        arr[0] = Vec::new();
        arr[1] = Vec::new();
        arr
    };
}

Meta

rustc 1.1.0 (35ceea399 2015-06-19)
binary: rustc
commit-hash: 35ceea3997c79a3b7562e89b462ab76af5b86b22
commit-date: 2015-06-19
host: x86_64-apple-darwin
release: 1.1.0

rustc 1.2.0-beta.4 (089f99c1c 2015-07-31)
binary: rustc
commit-hash: 089f99c1c40bd13d432fba7928bfefbbac13b3fa
commit-date: 2015-07-31
host: x86_64-apple-darwin
release: 1.2.0-beta.4

rustc 1.3.0-nightly (83b9deaf2 2015-08-01)
binary: rustc
commit-hash: 83b9deaf24200f6e41b1aec6fe090094f0190a7a
commit-date: 2015-08-01
host: x86_64-apple-darwin
release: 1.3.0-nightly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions