aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/struct.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-04-13 21:44:40 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-04-25 11:23:40 -0700
commita5c910adb610ae530db99f10aa77aaed3e85e830 (patch)
tree5c3f72dbac50fc9f09608be3d7ea328c629c00a0 /test/behavior/struct.zig
parent8d88dcdc61c61e3410138f4402482131f5074a80 (diff)
downloadzig-a5c910adb610ae530db99f10aa77aaed3e85e830.tar.gz
zig-a5c910adb610ae530db99f10aa77aaed3e85e830.zip
change semantics of `@memcpy` and `@memset`
Now they use slices or array pointers with any element type instead of requiring byte pointers. This is a breaking enhancement to the language. The safety check for overlapping pointers will be implemented in a future commit. closes #14040
Diffstat (limited to 'test/behavior/struct.zig')
-rw-r--r--test/behavior/struct.zig4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/behavior/struct.zig b/test/behavior/struct.zig
index d35b6aac9d..c3609e4a0a 100644
--- a/test/behavior/struct.zig
+++ b/test/behavior/struct.zig
@@ -91,7 +91,7 @@ test "structs" {
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
var foo: StructFoo = undefined;
- @memset(@ptrCast([*]u8, &foo), 0, @sizeOf(StructFoo));
+ @memset(@ptrCast([*]u8, &foo)[0..@sizeOf(StructFoo)], 0);
foo.a += 1;
foo.b = foo.a == 1;
try testFoo(foo);
@@ -498,7 +498,7 @@ test "packed struct fields are ordered from LSB to MSB" {
var all: u64 = 0x7765443322221111;
var bytes: [8]u8 align(@alignOf(Bitfields)) = undefined;
- @memcpy(&bytes, @ptrCast([*]u8, &all), 8);
+ @memcpy(bytes[0..8], @ptrCast([*]u8, &all));
var bitfields = @ptrCast(*Bitfields, &bytes).*;
try expect(bitfields.f1 == 0x1111);