| 1 | export fn a(x: [*]u8) void { |
| 2 | _ = x * 1; |
| 3 | } |
| 4 | |
| 5 | export fn b(x: *u8) void { |
| 6 | _ = x * x; |
| 7 | } |
| 8 | |
| 9 | export fn c() void { |
| 10 | const x: []u8 = undefined; |
| 11 | const y: []u8 = undefined; |
| 12 | _ = x - y; |
| 13 | } |
| 14 | |
| 15 | export fn d() void { |
| 16 | var x: [*]u8 = undefined; |
| 17 | var y: [*]u16 = undefined; |
| 18 | _ = &x; |
| 19 | _ = &y; |
| 20 | _ = x - y; |
| 21 | } |
| 22 | |
| 23 | comptime { |
| 24 | const x: *u8 = @ptrFromInt(1); |
| 25 | const y: *u16 = @ptrFromInt(2); |
| 26 | _ = x - y; |
| 27 | } |
| 28 | |
| 29 | comptime { |
| 30 | const x: *u0 = @ptrFromInt(1); |
| 31 | const y: *u0 = @ptrFromInt(2); |
| 32 | _ = x - y; |
| 33 | } |
| 34 | |
| 35 | // error |
| 36 | // |
| 37 | // :2:11: error: invalid pointer-integer arithmetic operator |
| 38 | // :2:11: note: pointer-integer arithmetic only supports addition and subtraction |
| 39 | // :6:11: error: invalid pointer-pointer arithmetic operator |
| 40 | // :6:11: note: pointer-pointer arithmetic only supports subtraction |
| 41 | // :12:11: error: invalid operands to binary expression: 'pointer' and 'pointer' |
| 42 | // :20:11: error: incompatible pointer arithmetic operands '[*]u8' and '[*]u16' |
| 43 | // :26:11: error: incompatible pointer arithmetic operands '*u8' and '*u16' |
| 44 | // :32:11: error: pointer subtraction requires element type 'u0' to have runtime bits |