zig build-obj source.zig -target riscv32-freestanding-none -femit-asm -fstrip -O ReleaseSmall
export fn store_hello() void {
inline for("Hello, World", 0..) |c, i|
@intToPtr([*]allowzero u8, 1)[i] = c;
}
correctly generates:
store_hello:
li a0, 72
sb a0, 1(zero)
li a0, 101
sb a0, 2(zero)
li a0, 108
sb a0, 3(zero)
sb a0, 4(zero)
li a1, 111
sb a1, 5(zero)
li a2, 44
sb a2, 6(zero)
li a2, 32
sb a2, 7(zero)
li a2, 87
sb a2, 8(zero)
sb a1, 9(zero)
li a1, 114
sb a1, 10(zero)
sb a0, 11(zero)
li a0, 100
sb a0, 12(zero)
ret
But this code:
export fn store_hello() void {
inline for("Hello, World", 0..) |c, i|
@intToPtr([*]allowzero u8, 0)[i] = c;
}
generates nothing. When adding volatile, it does work, but volatile shouldn't be required since it's already allowzero, right?