const std = @import("std");
test "aoeu" {
var arr: [10]u8 align(2) = undefined;
var x: usize = 1;
const ptr = ([*]u8)(&arr);
@compileLog(@typeOf(ptr));
const ptr2 = ptr + 1;
@compileLog(@typeOf(ptr2));
const ptr3 = ptr + x;
@compileLog(@typeOf(ptr3));
}
expected output:
| [*]align(2) u8
| [*]align(1) u8
| [*]align(1) u8
actual output:
| [*]align(2) u8
| [*]align(2) u8
| [*]align(2) u8
When we add a comptime known value to the pointer, we know what the new alignment should be.
When we add a runtime value to the pointer, it should make the type have alignment 1 no matter what, because the value could have made it unaligned.
expected output:
actual output:
When we add a comptime known value to the pointer, we know what the new alignment should be.
When we add a runtime value to the pointer, it should make the type have alignment 1 no matter what, because the value could have made it unaligned.