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+
5+void 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+
16+int main()
17+{
18+ f(2);
19+
20+ return 0;
21+}
tests/tests2/78_vla_label.expect+2−0
@@ -0,0 +1,2 @@
1+boom!
2+boom!
tests/tests2/Makefile+2−1
@@ -96,7 +96,8 @@ TESTS = \ · 95 unmodified lines
9696 74_nocode_wanted.test \
9797 75_array_in_struct_init.test \
9898 76_dollars_in_identifiers.test \
99− 77_push_pop_macro.test
99+ 77_push_pop_macro.test \
100+ 78_vla_label.test
100101
101102 # 34_array_assignment.test -- array assignment is not in C standard
102103