#zig build-obj {
--name test -fno-emit-bin
-Mroot=test.zig
#}

#write test.zig {
export fn foo() void {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: []u8 = &buf;
    const src: []align(1) u16 = @as([*]align(1) u16, @ptrCast(&buf))[0..4];

    @memmove(dest, src);
}

export fn bar() void {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: []u8 = &buf;
    const src: *align(1) [8]u16 = @ptrCast(&buf);

    @memmove(dest, src);
}

export fn baz() void {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: []u8 = &buf;
    const src: [*]align(1) u16 = @ptrCast(&buf);

    @memmove(dest, src);
}

export fn qux() void {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: *[8]u8 = &buf;
    const src: []align(1) u16 = @as([*]align(1) u16, @ptrCast(&buf))[0..4];

    @memmove(dest, src);
}

export fn quux() void {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: *[8]u8 = &buf;
    const src: *align(1) [8]u16 = @ptrCast(&buf);

    @memmove(dest, src);
}

export fn quuux() void {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: *[8]u8 = &buf;
    const src: [*]align(1) u16 = @ptrCast(&buf);

    @memmove(dest, src);
}

export fn foo2() void {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: []align(1) u16 = @as([*]align(1) u16, @ptrCast(&buf))[0..4];
    const src: []u8 = &buf;

    @memmove(dest, src);
}

export fn bar2() void {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: *align(1) [8]u16 = @ptrCast(&buf);
    const src: []u8 = &buf;

    @memmove(dest, src);
}

export fn baz2() void {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: [*]align(1) u16 = @ptrCast(&buf);
    const src: []u8 = &buf;

    @memmove(dest, src);
}

export fn qux2() void {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: []align(1) u16 = @as([*]align(1) u16, @ptrCast(&buf))[0..4];
    const src: *[8]u8 = &buf;

    @memmove(dest, src);
}

export fn quux2() void {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: *align(1) [8]u16 = @ptrCast(&buf);
    const src: *[8]u8 = &buf;

    @memmove(dest, src);
}

export fn quuux2() void {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: [*]align(1) u16 = @ptrCast(&buf);
    const src: *[8]u8 = &buf;

    @memmove(dest, src);
}

comptime {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: []u8 = &buf;
    const src: []align(1) u16 = @as([*]align(1) u16, @ptrCast(&buf))[0..4];
    @memmove(dest, src);
}

comptime {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: []u8 = &buf;
    const src: *align(1) [8]u16 = @ptrCast(&buf);
    @memmove(dest, src);
}

comptime {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: []u8 = &buf;
    const src: [*]align(1) u16 = @ptrCast(&buf);
    @memmove(dest, src);
}

comptime {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: *[8]u8 = &buf;
    const src: []align(1) u16 = @as([*]align(1) u16, @ptrCast(&buf))[0..4];
    @memmove(dest, src);
}

comptime {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: *[8]u8 = &buf;
    const src: *align(1) [8]u16 = @ptrCast(&buf);
    @memmove(dest, src);
}

comptime {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: *[8]u8 = &buf;
    const src: [*]align(1) u16 = @ptrCast(&buf);
    @memmove(dest, src);
}

comptime {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: []align(1) u16 = @as([*]align(1) u16, @ptrCast(&buf))[0..4];
    const src: []u8 = &buf;
    @memmove(dest, src);
}

comptime {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: *align(1) [8]u16 = @ptrCast(&buf);
    const src: []u8 = &buf;
    @memmove(dest, src);
}

comptime {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: [*]align(1) u16 = @ptrCast(&buf);
    const src: []u8 = &buf;
    @memmove(dest, src);
}

comptime {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: []align(1) u16 = @as([*]align(1) u16, @ptrCast(&buf))[0..4];
    const src: *[8]u8 = &buf;
    @memmove(dest, src);
}

comptime {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: *align(1) [8]u16 = @ptrCast(&buf);
    const src: *[8]u8 = &buf;
    @memmove(dest, src);
}

comptime {
    var buf: [8]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7 };
    const dest: [*]align(1) u16 = @ptrCast(&buf);
    const src: *[8]u8 = &buf;
    @memmove(dest, src);
}
#}
#update
#check errors {
test.zig:6:5: error: pointer element type 'u16' cannot coerce into element type 'u8'
test.zig:6:5: note: unsigned 8-bit int cannot represent all possible unsigned 16-bit values
test.zig:14:5: error: pointer element type 'u16' cannot coerce into element type 'u8'
test.zig:14:5: note: unsigned 8-bit int cannot represent all possible unsigned 16-bit values
test.zig:22:5: error: pointer element type 'u16' cannot coerce into element type 'u8'
test.zig:22:5: note: unsigned 8-bit int cannot represent all possible unsigned 16-bit values
test.zig:30:5: error: pointer element type 'u16' cannot coerce into element type 'u8'
test.zig:30:5: note: unsigned 8-bit int cannot represent all possible unsigned 16-bit values
test.zig:38:5: error: pointer element type 'u16' cannot coerce into element type 'u8'
test.zig:38:5: note: unsigned 8-bit int cannot represent all possible unsigned 16-bit values
test.zig:46:5: error: pointer element type 'u16' cannot coerce into element type 'u8'
test.zig:46:5: note: unsigned 8-bit int cannot represent all possible unsigned 16-bit values
test.zig:54:5: error: pointer element type 'u8' cannot coerce into element type 'u16'
test.zig:62:5: error: pointer element type 'u8' cannot coerce into element type 'u16'
test.zig:70:5: error: pointer element type 'u8' cannot coerce into element type 'u16'
test.zig:78:5: error: pointer element type 'u8' cannot coerce into element type 'u16'
test.zig:86:5: error: pointer element type 'u8' cannot coerce into element type 'u16'
test.zig:94:5: error: pointer element type 'u8' cannot coerce into element type 'u16'
test.zig:101:5: error: pointer element type 'u16' cannot coerce into element type 'u8'
test.zig:101:5: note: unsigned 8-bit int cannot represent all possible unsigned 16-bit values
test.zig:108:5: error: pointer element type 'u16' cannot coerce into element type 'u8'
test.zig:108:5: note: unsigned 8-bit int cannot represent all possible unsigned 16-bit values
test.zig:115:5: error: pointer element type 'u16' cannot coerce into element type 'u8'
test.zig:115:5: note: unsigned 8-bit int cannot represent all possible unsigned 16-bit values
test.zig:122:5: error: pointer element type 'u16' cannot coerce into element type 'u8'
test.zig:122:5: note: unsigned 8-bit int cannot represent all possible unsigned 16-bit values
test.zig:129:5: error: pointer element type 'u16' cannot coerce into element type 'u8'
test.zig:129:5: note: unsigned 8-bit int cannot represent all possible unsigned 16-bit values
test.zig:136:5: error: pointer element type 'u16' cannot coerce into element type 'u8'
test.zig:136:5: note: unsigned 8-bit int cannot represent all possible unsigned 16-bit values
test.zig:143:5: error: pointer element type 'u8' cannot coerce into element type 'u16'
test.zig:150:5: error: pointer element type 'u8' cannot coerce into element type 'u16'
test.zig:157:5: error: pointer element type 'u8' cannot coerce into element type 'u16'
test.zig:164:5: error: pointer element type 'u8' cannot coerce into element type 'u16'
test.zig:171:5: error: pointer element type 'u8' cannot coerce into element type 'u16'
test.zig:178:5: error: pointer element type 'u8' cannot coerce into element type 'u16'
#}
