Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / safestack / overflow.c
blobbaeac1c2afd444165ac0a6a3477d27d860cd0dcd
1 // RUN: %clang_safestack %s -o %t
2 // RUN: %run %t
4 // RUN: %clang_nosafestack -fno-stack-protector %s -o %t
5 // RUN: not %run %t
7 // Test that buffer overflows on the unsafe stack do not affect variables on the
8 // safe stack.
10 // REQUIRES: stable-runtime
12 extern void *memset(void *, int, __typeof__(sizeof(0)));
14 __attribute__((noinline))
15 void fct(volatile int *buffer)
17 memset(buffer - 1, 0, 7 * sizeof(int));
20 int main(int argc, char **argv)
22 int prebuf[7];
23 int value1 = 42;
24 int buffer[5];
25 int value2 = 42;
26 int postbuf[7];
27 fct(prebuf + 1);
28 fct(postbuf + 1);
29 fct(buffer);
30 return value1 != 42 || value2 != 42;