Skip to content
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

compiler segmentation fault when tagged unions in custom logging function #21704

Closed
texmex76 opened this issue Oct 15, 2024 · 2 comments
Closed
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@texmex76
Copy link

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

const std = @import("std");
pub const std_options = .{
    .logFn = myLogFn,
};
const UnionEnum = union(enum) {};
pub fn myLogFn(
    comptime l: anytype,
    comptime s: anytype,
    comptime f: anytype,
    a: UnionEnum,
) void {
    _ = l;
    _ = s;
    _ = f;
    _ = a;
}
pub fn main() void {}

When trying to build the above code using zig build-exe, the compiler segfaults:

[1]    13323 segmentation fault  zig build-exe main.zig

Expected Behavior

Expected the compiler to give any output and exit gracefully.

I looked a bit around and 18518 looks similar, but that one was already resolved and the compiler does not crash anymore for the input given in that bug report.

@texmex76 texmex76 added the bug Observed behavior contradicts documented or intended behavior label Oct 15, 2024
@rohlem
Copy link
Contributor

rohlem commented Oct 15, 2024

Still reproduces for me on newer version 0.14.0-dev.1579+f3445f8f6.
FYI, the issue is probably with your union type: Since it has no possible states, it is an uninstantiable type (aka noreturn-like), which aren't valid in arguments to called/instantiated functions. (See also #15909 for planned behavior.)
As you've stated though, the compiler crashing is a bug, it should instead result in a compile error pointing out the problem.
Update: As stated below, apparently there's a separate bug at play. After that it makes sense to re-test whether the compiler still crashes here or correctly reports the error.

@Vexu
Copy link
Member

Vexu commented Oct 15, 2024

Duplicate of #21099

@Vexu Vexu marked this as a duplicate of #21099 Oct 15, 2024
@Vexu Vexu closed this as not planned Won't fix, can't repro, duplicate, stale Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

3 participants