Skip to content

Taking @sizeOf an array of functions crashes the compiler for non-zero length arrays #24088

Open
@Trevor-Strong

Description

@Trevor-Strong

Zig Version

0.14.0

Steps to Reproduce and Observed Behavior

// test.zig
comptime {
   @compileLog(@sizeOf([1]fn () void))
}

Then, in a shell, run

$ zig test test.zig

The command will then exit abruptly with a non-zero exit code. I'm getting 3.

Expected Behavior

The compiler to not crash. Given how @sizeOf(struct{ fn () void }) == 0, it would make the most sense for @sizeOf([1]fn() void) to also be zero

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions