Let's ignore the comma's for now. The following line is giving me MISRA 10.4 violation because of col_size. If I change col_size to an int8_t, the violation goes away:
else if (x_in >= arr_x[col_size - 1])
I don't see any requirement that the index of an array must be the same type according to MISRA. I believe this is a false positive. unsigned ints should be allowed as array indexes for signed ints, and do not appear to be a violation of 10.4.
Regards,
Amir
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, Amir,
I think this is not a false positive, because 1 in this example have signed integer type, when col_size is unsigned uint8t. I suggest to use 1u instead:
else if (x_in >= arr_x[col_size - 1u])
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I'm wondering if the following is a false positive:
Let's ignore the comma's for now. The following line is giving me MISRA 10.4 violation because of col_size. If I change col_size to an int8_t, the violation goes away:
else if (x_in >= arr_x[col_size - 1])
I don't see any requirement that the index of an array must be the same type according to MISRA. I believe this is a false positive. unsigned ints should be allowed as array indexes for signed ints, and do not appear to be a violation of 10.4.
Regards,
Amir
Hello, Amir,
I think this is not a false positive, because 1 in this example have signed integer type, when col_size is unsigned uint8t. I suggest to use 1u instead:
else if (x_in >= arr_x[col_size - 1u])