| 1 | export fn a() void { |
| 2 | var x: [3]f32 = .{ 1, 2, 3 }; |
| 3 | takesSlice(&x); |
| 4 | } |
| 5 | |
| 6 | fn takesSlice(buf: []f32) void { |
| 7 | _ = buf; |
| 8 | } |
| 9 | |
| 10 | export fn b() void { |
| 11 | const x: [3]f32 = .{ 1, 2, 3 }; |
| 12 | for (comptime x[0..3]) |_| {} |
| 13 | for (&x) |_| {} |
| 14 | for (x[0..3]) |_| {} |
| 15 | } |
| 16 | |
| 17 | // error |
| 18 | // backend=selfhosted |
| 19 | // target=spirv32-opengl,spirv32-vulkan |
| 20 | // cpu_features=baseline+variable_pointers |
| 21 | // |
| 22 | // :3:16: error: cannot construct slice from address space 'generic' |
| 23 | // :3:16: note: only 'shared' and 'storage_buffer' address spaces support slicing on SPIR-V |
| 24 | // :14:11: error: cannot construct slice from address space 'generic' |
| 25 | // :14:11: note: only 'shared' and 'storage_buffer' address spaces support slicing on SPIR-V |