History

VLA fix [1/3]: added testcase demonstrating VLA bug

Joe Soroka committed 15 years ago

Commit cb2fa5e1 parent 174d61a1 file · +6 −1Browse files

Unified · Split

tests/tcctest.c+6−1
@@ -2079,9 +2079,14 @@ void *bounds_checking_is_enabled() · 2078 unmodified lines
20792079 void c99_vla_test(int size1, int size2)
20802080 {
20812081 #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];
20832084 void *tab1_ptr, *tab2_ptr, *bad_ptr;
20842085
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+
20852090 printf("Test C99 VLA 1 (sizeof): ");
20862091 printf("%s\n", (sizeof tab1 == size1 * size2 * 2 * sizeof(int)) ? "PASSED" : "FAILED");
20872092 tab1_ptr = tab1;