Skip to content

Instantly share code, notes, and snippets.

@mikdusan
Created April 3, 2020 00:09
Show Gist options
  • Save mikdusan/947d26b4378e3bf0d8a69b9e8b8b2e0d to your computer and use it in GitHub Desktop.
Save mikdusan/947d26b4378e3bf0d8a69b9e8b8b2e0d to your computer and use it in GitHub Desktop.
export fn foo1() void {
comptime {
var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
var target: [*]u8 = &buf;
const slice = target[0..3 :0];
// above after resolving slice instruction target,
// debugger shows `target`: (ZigValue).data.x_ptr.special == ConstPtrSpecialBaseArray
}
}
export fn foo2() void {
comptime {
var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
var target: [*]u8 = @ptrCast([*]u8, &buf);
const slice = target[0..3 :0];
// above after resolving slice instruction target,
// debugger shows `target`: (ZigValue).data.x_ptr.special == ConstPtrSpecialRef
}
}
pub fn panic(msg: []const u8, error_return_trace: ?*@import("builtin").StackTrace) noreturn {
while (true) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment