aboutsummaryrefslogtreecommitdiff
path: root/test/standalone/zerolength_check/src/main.zig
blob: 2f674ab4ff0aa086c4a85bdde01796e086ff7653 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const std = @import("std");

test {
    const dest = foo();
    const source = foo();

    @memcpy(dest, source);
    @memmove(dest, source);
    @memset(dest, 4);
    @memset(dest, undefined);

    const dest2 = foo2();
    @memset(dest2, 0);
}

fn foo() []u8 {
    const ptr = comptime std.mem.alignBackward(usize, std.math.maxInt(usize), 1);
    return @as([*]align(1) u8, @ptrFromInt(ptr))[0..0];
}

fn foo2() []u64 {
    const ptr = comptime std.mem.alignBackward(usize, std.math.maxInt(usize), 1);
    return @as([*]align(1) u64, @ptrFromInt(ptr))[0..0];
}