We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
0.10.0-dev.3952+9e070b653
This issue was discovered by a user on telegram (posting on their behalf as they don't have a github account).
build the following
comptime capacity: fn () u64 = capacity_, // comptime capacity: *const fn () u64 = capacity_, fn capacity_() u64 { return 64; } pub export fn _start() void { _ = (@This(){}).capacity(); }
and for the second case, the given:
const print = @import("std").debug.print; const Auto = struct { auto: [max_len]u8 = undefined, offset: u64 = 0, comptime capacity: *const fn () u64 = capacity, const max_len: u64 = 32; fn length(heap: Auto) u64 { return heap.offset; } fn capacity() u64 { return max_len; } }; const Heap = struct { start: u64, next: u64, finish: u64, fn length(heap: Heap) u64 { return heap.next - heap.start; } fn capacity(heap: Heap) u64 { return heap.finish - heap.start; } }; fn doPrint(any: anytype) void { print("offset: {d}, capacity: {d}\n", .{ any.length(), any.capacity() }); } pub fn main() void { const a: Auto = .{ .offset = 16, .capacity = Auto.capacity }; const b: Heap = .{ .start = 0x4000000, .next = 0x4000010, .finish = 0x4000020 }; doPrint(a); doPrint(b); }
Compile as this works with stage1 (first example) and not generate invalid IR (second example).
Segfault
> zig build-exe c.zig fish: Job 1, 'zig build-exe c.zig' terminated by signal SIGSEGV (Address boundary error)
For the second one, invalid IR
><> zig run c.zig LLVM Emit Object... LLVM ERROR: Cannot select: 0x7fa0816eeaf0: ch,glue = X86ISD::CALL 0x7fa0816eeb58, 0x7fa0816d6d90, RegisterMask:Untyped, c.zig:30:72 0x7fa0816d6d90: i8,ch = CopyFromReg 0x7fa0818ad3e8, Register:i8 %4, c.zig:30:72 0x7fa0816ef2a8: i8 = Register %4 0x7fa0816d6ec8: Untyped = RegisterMask In function: c.doPrint__anon_3733
The text was updated successfully, but these errors were encountered:
Sema: handle comptime fields in field call bind
145152b
Closes ziglang#12801
5e4483f
11b4493
No branches or pull requests
Zig Version
0.10.0-dev.3952+9e070b653
Steps to Reproduce
This issue was discovered by a user on telegram (posting on their behalf as they don't have a github account).
build the following
and for the second case, the given:
Expected Behavior
Compile as this works with stage1 (first example) and not generate invalid IR (second example).
Actual Behavior
Segfault
For the second one, invalid IR
The text was updated successfully, but these errors were encountered: