diff options
| author | Joe Soroka <gits@joesoroka.com> | 2011-04-08 01:07:17 -0700 |
|---|---|---|
| committer | Joe Soroka <gits@joesoroka.com> | 2011-04-08 01:07:17 -0700 |
| commit | cb2fa5eab920b2cc847ccdaab4973eca47007af4 (patch) | |
| tree | 3603484bee22b660fe4225c30cd367555d5793da /tests/tcctest.c | |
| parent | 174d61a56e0bede1c78d2da97a02d68ae1003416 (diff) | |
| download | tinycc-cb2fa5eab920b2cc847ccdaab4973eca47007af4.tar.gz tinycc-cb2fa5eab920b2cc847ccdaab4973eca47007af4.tar.bz2 | |
VLA fix [1/3]: added testcase demonstrating VLA bug
Diffstat (limited to 'tests/tcctest.c')
| -rw-r--r-- | tests/tcctest.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/tcctest.c b/tests/tcctest.c index 5192d40..8d558e3 100644 --- a/tests/tcctest.c +++ b/tests/tcctest.c @@ -2079,9 +2079,14 @@ void *bounds_checking_is_enabled() void c99_vla_test(int size1, int size2) { #if defined __i386__ || defined __x86_64__ - int tab1[size1 * size2][2], tab2[10][2]; + int size = size1 * size2; + int tab1[size][2], tab2[10][2]; void *tab1_ptr, *tab2_ptr, *bad_ptr; + /* "size" should have been 'captured' at tab1 declaration, + so modifying it should have no effect on VLA behaviour. */ + size = size-1; + printf("Test C99 VLA 1 (sizeof): "); printf("%s\n", (sizeof tab1 == size1 * size2 * 2 * sizeof(int)) ? "PASSED" : "FAILED"); tab1_ptr = tab1; |
