This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Bug in evaluation of parameter


Input parameters for mapping are in range: [ -9 ... 0]
Incorrect evaluation occurs when 0 (no error) is passed.
Rest parameters (-1 ... -9) are OK.

No optimization. Debug configuration of project..
Compiler: ARM 5.1.7

#include <stdio.h>

int err_to_errno_table[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

#define ERR_TO_ERRNO_TABLE_SIZE ( sizeof(err_to_errno_table) / sizeof(err_to_errno_table[0]) )

int main ( void ) {

    int err_code = 0;
	
    if ( (-(err_code)) < ERR_TO_ERRNO_TABLE_SIZE ) {
        printf ( "Ok \r\n" );
    } else  {
        printf ( "Bad \r\n" );
    }

    return 0;
}