Branch: Tag:

2013-03-06

2013-03-06 19:06:50 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler (amd64): Fixed bug in F_POS_INT_INDEX.

The range check in F_POS_INT_INDEX used the wrong comparison opcode
which caused indexing of arrays with their size to be allowed.

Added some corresponding tests to the testsuite.

Thanks to Stewa for the report.

2353:    mov_mem32_reg( REG_RDX, OFFSETOF(array,size), REG_RCX );    mov_imm_reg( b, REG_RBX);    cmp_reg_reg( REG_RCX, REG_RBX ); -  jg( &label_A ); /* b > RBX, index outside array */ +  jge( &label_A ); /* b >= RBX, index outside array */    shl_reg_imm( REG_RBX, 4 );    add_reg_mem( REG_RBX, REG_RDX, OFFSETOF(array,item) );   
2404:       LABEL_D;    cmp_reg32_imm( REG_RBX, 0 ); jl( &label_B ); // <0 -  cmp_reg_reg( REG_RBX, REG_RCX); jge( &label_B ); // >size +  cmp_reg_reg( REG_RBX, REG_RCX); jge( &label_B ); // >=size       /* array, index inside array. push item, swap, pop, done */    mov_mem_reg( REG_RCX, OFFSETOF(array,item), REG_RCX );