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
2079void c99_vla_test(int size1, int size2)2079void c99_vla_test(int size1, int size2)
2080{2080{
2081#if defined __i386__ || defined __x86_64__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 void *tab1_ptr, *tab2_ptr, *bad_ptr;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 printf("Test C99 VLA 1 (sizeof): ");2090 printf("Test C99 VLA 1 (sizeof): ");
2086 printf("%s\n", (sizeof tab1 == size1 * size2 * 2 * sizeof(int)) ? "PASSED" : "FAILED");2091 printf("%s\n", (sizeof tab1 == size1 * size2 * 2 * sizeof(int)) ? "PASSED" : "FAILED");
2087 tab1_ptr = tab1;2092 tab1_ptr = tab1;