aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/nested_ptr_cast_bad_operand.zig
blob: f8d656b0bded5bb83bac1fe9c4e30e0c96f6650c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const p: ?*const u8 = null;
export fn a() void {
    _ = @as(*const u32, @ptrCast(@alignCast(p)));
}
export fn b() void {
    _ = @constCast(@volatileCast(123));
}
export fn c() void {
    const x: ?*f32 = @ptrCast(@addrSpaceCast(@constCast(@volatileCast(p))));
    _ = x;
}

// error
//
// :3:45: error: null pointer casted to type '*const u32'
// :6:34: error: expected pointer type, found 'comptime_int'
// :9:22: error: @ptrCast increases pointer alignment
// :9:71: note: '?*const u8' has alignment '1'
// :9:22: note: '?*f32' has alignment '4'
// :9:22: note: use @alignCast to assert pointer alignment