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