#zig build-obj { --name test -fno-emit-bin -Mroot=test.zig #} #write test.zig { export fn a(x: [*]u8) void { _ = x * 1; } export fn b(x: *u8) void { _ = x * x; } export fn c() void { const x: []u8 = undefined; const y: []u8 = undefined; _ = x - y; } export fn d() void { var x: [*]u8 = undefined; var y: [*]u16 = undefined; _ = &x; _ = &y; _ = x - y; } comptime { const x: *u8 = @ptrFromInt(1); const y: *u16 = @ptrFromInt(2); _ = x - y; } comptime { const x: *u0 = @ptrFromInt(1); const y: *u0 = @ptrFromInt(2); _ = x - y; } #} #update #check errors { test.zig:2:11: error: invalid pointer-integer arithmetic operator test.zig:2:11: note: pointer-integer arithmetic only supports addition and subtraction test.zig:6:11: error: invalid pointer-pointer arithmetic operator test.zig:6:11: note: pointer-pointer arithmetic only supports subtraction test.zig:12:11: error: invalid operands to binary expression: 'pointer' and 'pointer' test.zig:20:11: error: incompatible pointer arithmetic operands '[*]u8' and '[*]u16' test.zig:26:11: error: incompatible pointer arithmetic operands '*u8' and '*u16' test.zig:32:11: error: pointer subtraction requires element type 'u0' to have runtime bits #}