Skip to content

Compiler segfaults using @unionInit with a slice of runtime scalar #24175

Open
@doclic

Description

@doclic

Zig Version

0.14.1

Steps to Reproduce and Observed Behavior

The compiler will crash with a SIGSEGV when trying to compile this code:

pub const Foo = union(enum) {
    a: void,
};
pub var bar: u8 = 'a';

pub fn main() void {
    _ = @unionInit(Foo, &.{bar}, {});
}

Command used was zig build-exe example.zig

Expected Behavior

An error, as this code is still not correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions