Skip to content

Commit 41675a7

Browse files
committed
strengthen test_alloca to check alignment
1 parent 0d1f0bd commit 41675a7

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

tests/core/test_alloca.in

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
#include <stdio.h>
22
#include <stdlib.h>
3+
#include <assert.h>
34

4-
int main() {
5-
char *pc;
6-
pc = (char *)alloca(5);
7-
printf("z:%d*%d*\n", pc > 0, (int)pc);
5+
int main(int argc, char **argv) {
6+
char *pc, *pc2;
7+
assert(argc == 1);
8+
pc = (char *)alloca(4+argc);
9+
assert(((int)pc) % 4 == 0);
10+
pc2 = (char *)alloca(4+argc);
11+
assert(((int)pc2) % 4 == 0);
12+
printf("z:%d*%d*%d*\n", pc > 0, (int)pc, (int)pc2);
813
return 0;
914
}

tests/test_core.py

+2
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,8 @@ def test_emptyclass(self):
16061606
self.do_run_from_file(src, output)
16071607

16081608
def test_alloca(self):
1609+
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('non-ta2 may have unaligned allocas')
1610+
16091611
test_path = path_from_root('tests', 'core', 'test_alloca')
16101612
src, output = (test_path + s for s in ('.in', '.out'))
16111613

0 commit comments

Comments
 (0)