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

// error
// backend=stage2
// target=native
//
// :3:23: error: cast 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