diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-09-19 14:36:41 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-09-20 00:50:13 +0300 |
| commit | 541b3e3a31946475f29d21e7a742bf80c5952791 (patch) | |
| tree | 4516d103301ab7913786679f3f2e988bf7029eb5 /test/cases/compile_errors/implicitly_increasing_slice_alignment.zig | |
| parent | fb91483e48fe6cfa21edc613f266e27bd6bf9dbf (diff) | |
| download | zig-541b3e3a31946475f29d21e7a742bf80c5952791.tar.gz zig-541b3e3a31946475f29d21e7a742bf80c5952791.zip | |
Sema: check pointer qualifiers before implicit cast
Closes #12881
Diffstat (limited to 'test/cases/compile_errors/implicitly_increasing_slice_alignment.zig')
| -rw-r--r-- | test/cases/compile_errors/implicitly_increasing_slice_alignment.zig | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/cases/compile_errors/implicitly_increasing_slice_alignment.zig b/test/cases/compile_errors/implicitly_increasing_slice_alignment.zig new file mode 100644 index 0000000000..84ec6464f4 --- /dev/null +++ b/test/cases/compile_errors/implicitly_increasing_slice_alignment.zig @@ -0,0 +1,21 @@ +const Foo = packed struct { + a: u8, + b: u32, +}; + +export fn entry() void { + var foo = Foo { .a = 1, .b = 10 }; + foo.b += 1; + bar(@as(*[1]u32, &foo.b)[0..]); +} + +fn bar(x: []u32) void { + x[0] += 1; +} + +// error +// backend=stage2 +// target=native +// +// :9:22: error: expected type '*[1]u32', found '*align(1) u32' +// :9:22: note: pointer alignment '1' cannot cast into pointer alignment '4' |
