Skip to content

Corrupted initialization in the static struct #5688

Closed
@lifthrasiir

Description

@lifthrasiir
struct X { vec: &'static [int] }
static V: &'static [X] = &[X { vec: &[1, 2, 3] }];
fn main() {
    for V.each |&v| {
        io::println(fmt!("%?", v.vec));
    }
}

...should print &[1, 2, 3] but instead prints something like &[4492532864, 24]. It is pretty evident that the compiler messed up with the representation of [int, ..n] and [int] somehow, or at least failed to typecheck correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions