Zig: unable to call function with a new stack with a runtime known new stack slice

Created on 6 Dec 2019  路  1Comment  路  Source: ziglang/zig

With the merge of #3856, calling a function with a new stack regressed a bit:

export fn entry() void {
    var buf: [10]u8 align(16) = undefined;
    @call(.{.stack = &buf}, foo, .{});
}
fn foo() void {}

Used to be OK, now gives:

/home/andy/dev/zig/build/test.zig:3:5: error: unable to evaluate constant expression
    @call(.{ .stack = &buf }, foo, .{});
    ^

Need more Runtime Hint Propagation to make this work. However this is a low priority because it's not clear this feature is going to make it into zig.

Above example works if you make the memory global:

var buf: [10]u8 align(16) = undefined;
export fn entry() void {
    @call(.{.stack = &buf}, foo, .{});
}
fn foo() void {}
bug stage1

Most helpful comment

I hate this bug. @call is a great feature, but now it's broken.

>All comments

I hate this bug. @call is a great feature, but now it's broken.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jayschwa picture jayschwa  路  3Comments

jorangreef picture jorangreef  路  3Comments

S0urc3C0de picture S0urc3C0de  路  3Comments

andrewrk picture andrewrk  路  3Comments

zimmi picture zimmi  路  3Comments