//! returns: 0
//! Test storing through a pointer to a slice in static storage.

record Entry {
    a: u32,
    b: u32,
    c: u32,
    d: u32,
    e: u32,
}

record Table {
    entries: *mut [Entry],
    len: u32,
}

record PtrBox {
    ptr: *mut *mut [Entry],
}

static STORAGE: [Entry; 2] = undefined;
static TABLE: Table = undefined;
static HOLDER: PtrBox = undefined;

@default fn main() -> i32 {
    TABLE.entries = &mut STORAGE[..];
    TABLE.len     = 0;

    HOLDER.ptr = &mut TABLE.entries;

    HOLDER.ptr[0] = Entry { a: 1, b: 2, c: 3, d: 4, e: 5 };

    assert TABLE.entries.len == 2 and TABLE.entries.ptr == &STORAGE[0];
    assert STORAGE[0].a == 1 and STORAGE[0].e == 5;

    HOLDER.ptr[1] = Entry { a: 10, b: 20, c: 30, d: 40, e: 50 };

    assert TABLE.entries.len == 2 and TABLE.entries.ptr == &STORAGE[0];
    assert STORAGE[1].c == 30 and STORAGE[1].d == 40;
    return 0;
}
