In gcc 4.3.3 when array subscripts are expressions which contain a mix of signed and unsigned operands the result will be unsigned. It's a cause of crashes in the interpreter. The attached patch fixes the crashes but it's possible that there are other codepaths which are similarly broken. A simple testcase to see if you can reproduce it with the compiler of your choice is: #define CRASH 0 int array[] = { -50, -40, -30, -20, -10, 0, 10, 20, 30, 40, 50 }; int main(int argc, char **) { int *ptr = array + 5; unsigned i = argc; int k = 3 * i; #if CRASH int num = ptr[i - k]; #else int num = ptr[(int)(i - k)]; #endif fprintf(stderr, "num is %d\n", num); }
Created attachment 32337 [details] simple fix
Created attachment 32361 [details] fixeration!
Comment on attachment 32361 [details] fixeration! Test case? Why int32_t instead of just int? r=me
Committed r45693
*** Bug 26116 has been marked as a duplicate of this bug. ***
*** Bug 26553 has been marked as a duplicate of this bug. ***