jyn514 / saltwater

A C compiler written in Rust, with a focus on good error messages.
BSD 3-Clause "New" or "Revised" License
290 stars 27 forks source link

Variable Length Arrays #63

Open jyn514 opened 5 years ago

jyn514 commented 5 years ago

Thanks to Tachyon

int main() {
        int n = 1;
        int a[n];
        return *a;
}
<stdin>:3:9: error: not a constant expression
jyn514 commented 5 years ago

It may be more elegant to first implement alloca as a builtin and then implement this in terms of alloca.

xTachyon commented 4 years ago

Idea - always allocate the same space for a vla and at runtime check if you have enough static allocated space, yay, otherwise crash or something.

It's not ideal, but it's better than nothing.

Remind @jyn514 in 2 months to check for cranelift support.