Skip to content

Compiler crash: Violated assert: expr->resolve_status == RESOLVE_DONE on compound assignment to compile-time array element #3419

Description

@ManuLinares
module test_repro;

macro void trigger_crash(int x) {
    int[4] $masks = {};

    // ANY of these compound assignments to a compile-time array element 
    // will trigger the compiler crash (assert: resolve_status == RESOLVE_DONE)
    // (the compiler misses validation for 'EXPR_COMPOUND_ASSIGN' nodes ?)
    
    // $masks[1] += x;  // Variant 1: Compound addition
    // $masks[1] |= x;  // Variant 2: Compound bitwise OR
    // $masks[1] -= x;  // Variant 3: Compound subtraction
    // $masks[1] *= x;  // Variant 4: Compound multiplication
    $masks[1] <<= x;   // Variant 5: Compound left shift
}

fn void main() {
    trigger_crash(42);
}
⚠️ The compiler encountered an unexpected error: "Violated assert: expr->resolve_status == RESOLVE_DONE".

- Function: expr_is_const_initializer(...)
- Source file: /home/mb/scripts/c3c/src/compiler/compiler_internal.h:4718

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugSomething isn't workingFixed needs testingNeeds verification / testing that it now works

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions