Skip to content

Returning value from block inside comptime block triggers assertion in stage1/ir.cpp, ir_start_bb #7386

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
michaelbartnett opened this issue Dec 10, 2020 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@michaelbartnett
Copy link
Contributor

This happens inside functions as well, but only a file-scope comptime block is necessary to repro.

comptime {
    var val = blk: {
        if (false) { // if (true) also asserts
            break :blk false;
        }
        break :blk true;
    };
}
when analyzing <source>:2:20 in compiler source at /deps/zig/src/stage1/ir.cpp:13377: assertion failed. This is a bug in the Zig compiler.
Unable to dump stack trace: debug info stripped
ASM generation compiler returned: 255
when analyzing <source>:2:20 in compiler source at /deps/zig/src/stage1/ir.cpp:13377: assertion failed. This is a bug in the Zig compiler.
Unable to dump stack trace: debug info stripped
Execution build compiler returned: 255

Error log from https://godbolt.org/z/61hTG4

Source context:

static void ir_start_bb(IrAnalyze *ira, IrBasicBlockSrc *old_bb, IrBasicBlockSrc *const_predecessor_bb) {
    ir_assert(!old_bb->suspended, (old_bb->instruction_list.length != 0) ? &old_bb->instruction_list.at(0)->base : nullptr);
    ira->instruction_index = 0;
    ira->old_irb.current_basic_block = old_bb;
    ira->const_predecessor_bb = const_predecessor_bb;
    ira->old_bb_index = old_bb->index;
}
@Vexu Vexu added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. labels Dec 11, 2020
@Vexu Vexu added this to the 0.9.0 milestone Dec 11, 2020
@Vexu
Copy link
Member

Vexu commented Apr 20, 2021

Duplicate of #3376.

@Vexu Vexu closed this as completed Apr 20, 2021
@Vexu Vexu removed this from the 0.9.0 milestone Apr 20, 2021
@andrewrk andrewrk added this to the 0.8.0 milestone Jun 4, 2021
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 stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

No branches or pull requests

3 participants