aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/implicitly_increasing_slice_alignment.zig
blob: 171936097dc9e5993f6cea587e84f7a27943b213 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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'