Skip to content

(0.6.0) Compiler Bug: Assertion failed at eval_const_expr_implicit_cast #6705

@ghost

Description

I've been getting compiler crashes on a fairly large project of mine in 0.6.0, with the following output:

Assertion failed at [...]/compiler/zig/src/ir.cpp:12740 in eval_const_expr_implicit_cast. This is a bug in the Zig compiler.
[...]/compiler/zig/src-self-hosted/stage2.zig:37:5: 0x55bf92e96f1c in stage2_panic (zigstage2)
    @panic(ptr[0..len]);
    ^
[...]/compiler/zig/src/util.cpp:20:17: 0x55bf92e5167b in zig_panic ([...]/compiler/zig/src/util.cpp)
    stage2_panic("", 0);
                ^
[...]/compiler/zig/src/util_base.hpp:53:18: 0x55bf92da1d7f in zig_assert ([...]/compiler/zig/src/ir.cpp)
        zig_panic("Assertion failed at %s:%d in %s. This is a bug in the Zig compiler.", file, line, func);
                 ^
[...]/compiler/zig/src/ir.cpp:12740:17: 0x55bf92dced19 in eval_const_expr_implicit_cast ([...]/compiler/zig/src/ir.cpp)
                assert(new_type->id == ZigTypeIdFloat);
                ^
[...]/compiler/zig/src/ir.cpp:12821:43: 0x55bf92dcf17b in ir_resolve_cast ([...]/compiler/zig/src/ir.cpp)
        if (!eval_const_expr_implicit_cast(ira, source_instr, cast_op, value->value, value->value->type,
                                          ^
[...]/compiler/zig/src/ir.cpp:26077:27: 0x55bf92e02615 in ir_analyze_instruction_int_to_float ([...]/compiler/zig/src/ir.cpp)
    return ir_resolve_cast(ira, &instruction->base.base, target, dest_type, CastOpIntToFloat);
                          ^
[...]/compiler/zig/src/ir.cpp:30404:55: 0x55bf92e1276c in ir_analyze_instruction_base ([...]/compiler/zig/src/ir.cpp)
            return ir_analyze_instruction_int_to_float(ira, (IrInstSrcIntToFloat *)instruction);
                                                      ^
[...]/compiler/zig/src/ir.cpp:30626:65: 0x55bf92e132de in ir_analyze ([...]/compiler/zig/src/ir.cpp)
        IrInstGen *new_instruction = ir_analyze_instruction_base(ira, old_instruction);
                                                                ^
[...]/compiler/zig/src/analyze.cpp:4836:44: 0x55bf92e61ce0 in analyze_fn_ir ([...]/compiler/zig/src/analyze.cpp)
    ZigType *block_return_type = ir_analyze(g, fn->ir_executable,
                                           ^
[...]/compiler/zig/src/analyze.cpp:4952:18: 0x55bf92e622ae in analyze_fn_body ([...]/compiler/zig/src/analyze.cpp)
    analyze_fn_ir(g, fn_table_entry, return_type_node);
                 ^
[...]/compiler/zig/src/analyze.cpp:5064:28: 0x55bf92e62b4f in semantic_analyze ([...]/compiler/zig/src/analyze.cpp)
            analyze_fn_body(g, fn_entry);
                           ^
[...]/compiler/zig/src/codegen.cpp:9725:25: 0x55bf92d8d0bc in gen_root_source ([...]/compiler/zig/src/codegen.cpp)
        semantic_analyze(g);
                        ^
[...]/compiler/zig/src/codegen.cpp:10830:28: 0x55bf92d9177b in codegen_build_and_link ([...]/compiler/zig/src/codegen.cpp)
            gen_root_source(g);
                           ^
[...]/compiler/zig/src/main.cpp:1662:39: 0x55bf92d61580 in main0 ([...]/compiler/zig/src/main.cpp)
                codegen_build_and_link(g);
                                      ^
[...]/compiler/zig/src/main.cpp:1849:24: 0x55bf92d62104 in main ([...]/compiler/zig/src/main.cpp)
    auto result = main0(argc, argv);
                       ^
???:?:?: 0x7f7e16b770b2 in ??? (???)
untitled_simulationulation...The following command terminated unexpectedly:
[...]/compiler/zig/build/zig build-exe [...]/untitled_sim/src/engine.zig --library c --library X11 --library GL --c-source -std=c99 [...]/untitled_sim/src/engine/c/sokol.c --release-fast --cache-dir [...]/untitled_sim/zig-cache --name untitled_simulationulation -I [...]/untitled_sim/src/engine/c/sokol --main-pkg-path [...]/untitled_sim/src --cache on 

Build failed. The following command failed:
[...]/untitled_sim/zig-cache/o/VGfDv2CaRWSMaPFGLRNNxtKqY_X7p5hZ-IDhh09FQB-PQQzY9Z4sgm3qUIcXxGZO/build [...]/compiler/zig/build/zig [...]/untitled_sim [...]/untitled_sim/zig-cache

...which is different from the ir_gen_negation crash.

I am quite confused, and any help would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions