Luuk de Gram 37e2a04da8
add stand alone test to verify bulk-memory features
This adds a standalone test case to ensure the runtime does not trap
when performing a memory.copy or memory.fill instruction while the
destination or source address is out-of-bounds and the length is 0.
2023-07-10 20:05:13 +02:00

24 lines
529 B
Zig

const std = @import("std");
test {
var dest = foo();
var source = foo();
@memcpy(dest, source);
@memset(dest, 4);
@memset(dest, undefined);
var 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];
}