Unified · Split
| @@ -2079,9 +2079,14 @@ void *bounds_checking_is_enabled() · 2078 unmodified lines | ||
| 2079 | 2079 | void c99_vla_test(int size1, int size2) |
| 2080 | 2080 | { |
| 2081 | 2081 | #if defined __i386__ || defined __x86_64__ |
| 2082 | − int tab1[size1 * size2][2], tab2[10][2]; | |
| 2082 | + int size = size1 * size2; | |
| 2083 | + int tab1[size][2], tab2[10][2]; | |
| 2083 | 2084 | void *tab1_ptr, *tab2_ptr, *bad_ptr; |
| 2084 | 2085 | |
| 2086 | + /* "size" should have been 'captured' at tab1 declaration, | |
| 2087 | + so modifying it should have no effect on VLA behaviour. */ | |
| 2088 | + size = size-1; | |
| 2089 | + | |
| 2085 | 2090 | printf("Test C99 VLA 1 (sizeof): "); |
| 2086 | 2091 | printf("%s\n", (sizeof tab1 == size1 * size2 * 2 * sizeof(int)) ? "PASSED" : "FAILED"); |
| 2087 | 2092 | tab1_ptr = tab1; |