Skip to content

Coercion of [][*:0]u8 to [][*:0]const u8 in function call causes broken LLVM module #7807

New issue

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

Closed
ifreund opened this issue Jan 17, 2021 · 2 comments
Milestone

Comments

@ifreund
Copy link
Member

ifreund commented Jan 17, 2021

Minimal reproducer:

const std = @import("std");
pub fn main() void {
    std.debug.print("{}\n", .{foo(std.os.argv)});
}
fn foo(bar: [][*:0]const u8) usize {
    return bar.len;
}

Result:

./build/zig version
0.8.0-dev.1000+3562edf13

./build/zig run /tmp/foo.zig                    
Code Generation [219/549] std.fs.path.joinSep... broken LLVM module found: Call parameter type does not match function signature!
%"[][*:0]u8"* @argv
 %"[][*:0]const u8"*  %1 = call fastcc i64 @foo(%"[][*:0]u8"* @argv), !dbg !15972

This is a bug in the Zig compiler.thread 7675 panic: 
Unable to dump stack trace: debug info stripped
zsh: abort      ./build/zig run /tmp/foo.zig
@ifreund
Copy link
Member Author

ifreund commented Jan 17, 2021

Note that this works:

const std = @import("std");
pub fn main() void {
    const argv: [][*:0]const u8 = std.os.argv;
    std.debug.print("{}\n", .{foo(argv)});
}
fn foo(bar: [][*:0]const u8) usize {
    return bar.len;
}

but removing the const causes it to fail again:

const std = @import("std");
pub fn main() void {
    const argv: [][*:0]u8 = std.os.argv;
    std.debug.print("{}\n", .{foo(argv)});
}
fn foo(bar: [][*:0]const u8) usize {
    return bar.len;
}

@ifreund ifreund changed the title Implicit cast of [][*:0]u8 to [][*:0]const u8 in function call cause broken LLVM module Coercion of [][*:0]u8 to [][*:0]const u8 in function call causes broken LLVM module Jan 17, 2021
@Vexu
Copy link
Member

Vexu commented Jan 26, 2021

Duplicate of #4907, #4123, #6147.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants