Skip to content

Compiler crash: runtime-conditional break/return inside inline loop #2727

@CurtisFenner

Description

@CurtisFenner

I'm building using zig 0.4.0+fcc0728 on 64 bit Windows 10, built from source in Release mode.

The following file run through zig test causes Zig to exit with no output and only empty files written to the zig-cache:

fn crash() !void {
    return error.Crash;
}

test "A problem happens" {
    inline for ([_]u8{ 0, 1 }) |x| {
        if (crash()) {} else |z| {
            return;
        }
    }
}

The exit code, according to an echo %errorlevel%, is -1073741819. The Windows Event Viewer has the following log:

Exception code: 0xc0000005
Fault offset: 0x0000000001d20690
Faulting process id: 0xac8

The test input is seemingly minimal. It doesn't crash with only one/zero elements, it doesn't crash if the return is removed, replaced with other code, or moved to the other branch (though break also causes it). It doesn't crash with a regular if/else. It doesn't crash if replaced with try or with catch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorstage1The process of building from source via WebAssembly and the C backend.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions