const std = @import("std");
pub fn main() void {
const a: []u8 = &.{};
const b: []i32 = &.{};
std.debug.print("{x}\n", .{@intFromPtr(a.ptr)});
std.debug.print("{x}\n", .{@intFromPtr(b.ptr)});
std.debug.print("{x}\n", .{@intFromPtr(&.{})});
}
The above code compiles without an error and prints this:
aaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaa
Seems like &.{}
is always aaaaaaaaaaaaaaaa
even if it’s compiled with ReleaseFast
.
Is it ok to assign &.{}
to a slice?