History

add test case for VLA segfaults

This test obviously shouldn't segfault, but currently does so. The problem is in the VLA code, which fails to save the stack pointer before taking a conditional branch in some cases. See this thread: http://lists.nongnu.org/archive/html/tinycc-devel/2015-04/msg00130.html

Philip committed 11 years ago

Commit bd489a41 parent bbcb54a3 files · +25 −1Browse files

Unified · Split

3 files
  1. tests/tests2/78_vla_label.c +21 −0
  2. tests/tests2/78_vla_label.expect +2 −0
  3. tests/tests2/Makefile +2 −1
tests/tests2/78_vla_label.c+21−0
@@ -0,0 +1,21 @@
1#include <stdio.h>
2
3/* This test segfaults as of April 27, 2015. */
4
5void f(int argc)
6{
7 char test[argc];
8 if(0)
9 label:
10 printf("boom!\n");
11 if(argc-- == 0)
12 return;
13 goto label;
14}
15
16int main()
17{
18 f(2);
19
20 return 0;
21}
tests/tests2/78_vla_label.expect+2−0
@@ -0,0 +1,2 @@
1boom!
2boom!
tests/tests2/Makefile+2−1
@@ -96,7 +96,8 @@ TESTS = \ · 95 unmodified lines
96 74_nocode_wanted.test \96 74_nocode_wanted.test \
97 75_array_in_struct_init.test \97 75_array_in_struct_init.test \
98 76_dollars_in_identifiers.test \98 76_dollars_in_identifiers.test \
99 77_push_pop_macro.test99 77_push_pop_macro.test \
100 78_vla_label.test
100 101
101# 34_array_assignment.test -- array assignment is not in C standard102# 34_array_assignment.test -- array assignment is not in C standard
102 103