Activity for Job Noorman

  • Job Noorman Job Noorman posted a comment on discussion Development

    I'll try to make the problem we have a bit more concrete. We have products that can have a number of antennas which are identified in code like this: enum Antennas { ANT_MAIN = 0, ANT_AUX1, ANT_AUX2, ANT_LAST }; This enum is then used throughout the code as follows: void f() { int antenna_info[ANT_LAST]; if (ANT_AUX2 < ANT_LAST) antenna_info[ANT_AUX2] = 42; } This works fine in configurations with all three antennas. However, if the product has less antennas, the enum is defined like this (this example...

  • Job Noorman Job Noorman modified a comment on discussion Development

    I found a similar example which reports an unexpected error. Given the following assert definition: #define assert(c) if(!(c)) exit(1) Then this reports an out of bounds condition: int array[4]; assert(false); array[4] = 1; Interestingly, the following does not: int array[4]; int i = 4; assert(false); array[i] = 1; Similarly, the following also does not give an error: int array[4]; int i = 4; if (false) array[i] = 1; (The last two examples do report an error without the assert.) So it seems that...

  • Job Noorman Job Noorman posted a comment on discussion Development

    I found a similar example which reports an unexpected error. Given the following assert definition: #define assert(c) if(!(c)) exit(1) Then this reports an out of bounds condition: int array[4]; assert(false); array[4] = 1; Interestingly, the following does not: int array[4]; int i = 4; assert(false); array[i] = 1; Similarly, the following also does not give an error: int array[4]; int i = 4; if (false) array[i] = 1; (The latter two examples do report an error without the assert.) So it seems that...

  • Job Noorman Job Noorman posted a comment on discussion Development

    Take the following example: int main() { int array[4]; if (false) array[4] = 1; } Cppcheck reports an out of bounds access here although the branch is clearly never executed. Am I correct in considering this a bug? I would like to add that this example is clearly contrived and would never occur in real code. However, it was actually distilled from a real code base were both the condition and the array access depended on defines which, in a particular configuration, ended-up producing code similar...

  • Job Noorman Job Noorman committed [0bf3c9]

    Test commit to see if write access works.

1