graphitemaster / gmqcc

An Improved Quake C Compiler
Other
163 stars 29 forks source link

if bug #199

Closed terencehill closed 3 years ago

terencehill commented 3 years ago

This code compiles and when executed prints 4, but it shouldn't since k is defined inside the if block.

void print(string a) = #1;
string ftos(float i) = #2;
string strcat(string a, string b) = #10;

void main() {
    if(1)
        float k = 4;
    print(strcat(ftos(k), "\n"));
}

Adding curly braces around float k = 4; gmqcc correctly refuses to compile it.

Compiled and executed with ./gmqcc -std=gmqcc -freturn-assignments idk.qc -o out.dat && ./qcvm out.dat

graphitemaster commented 3 years ago

Fixed in 1e8ce17