Closed
Description
Found on the latest master build.
Code:
const expect = @import("std").testing.expect;
fn fibonacciTailInternal(n: u16, a: u16, b: u16) u16 {
if (n == 0) return a;
if (n == 1) return b;
return @call(
.{ .modifier = .always_tail },
fibonacciTailInternal,
.{ n - 1, b, a + b },
);
}
fn fibonacciTail(n: u16) u16 {
return fibonacciTailInternal(n, 0, 1);
}
test "forced tail call" {
try expect(fibonacciTail(10) == 55);
}
Output:
> zig test main.zig
Code Generation [676/921] std.math.log2_int... broken LLVM module found: musttail call must precede a ret with an optional bitcast
%21 = musttail call fastcc i16 @fibonacciTailInternal(i16 %13, i16 %15, i16 %19), !dbg !3846
This is a bug in the Zig compiler.thread 178562 panic:
Unable to dump stack trace: debug info stripped
Aborted (core dumped)