aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/increase_pointer_alignment_in_ptrCast.zig
blob: a297d3e2af2466fa9054de21a07a4f5811884c9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
export fn entry() u32 {
    var bytes: [4]u8 = [_]u8{ 0x01, 0x02, 0x03, 0x04 };
    const ptr: *u32 = @ptrCast(&bytes[0]);
    return ptr.*;
}

// error
//
// :3:23: error: @ptrCast increases pointer alignment
// :3:32: note: '*u8' has alignment '1'
// :3:23: note: '*u32' has alignment '4'
// :3:23: note: use @alignCast to assert pointer alignment