Created
April 3, 2020 00:09
-
-
Save mikdusan/947d26b4378e3bf0d8a69b9e8b8b2e0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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