1// RUN: %clang_safestack %s -o %t
2// RUN: %run %t
3
4#include "utils.h"
5
6// Test that loads/stores work correctly for variables on the unsafe stack.
7
8int main(int argc, char **argv)
9{
10 int i;
11 char buffer[128];
12
13 // check that we can write to a buffer
14 for (i = 0; argv[0][i] && i < sizeof (buffer) - 1; ++i)
15 buffer[i] = argv[0][i];
16 buffer[i] = '\0';
17
18 break_optimization(arg: buffer);
19
20 // check that we can read from a buffer
21 for (i = 0; argv[0][i] && i < sizeof (buffer) - 1; ++i)
22 if (buffer[i] != argv[0][i])
23 return 1;
24 return 0;
25}
26

source code of compiler-rt/test/safestack/buffer-copy.c