Home | History | Annotate | Download | only in safestack
      1 // RUN: %clang_safestack %s -o %t
      2 // RUN: %run %t
      3 
      4 // RUN: %clang_nosafestack -fno-stack-protector %s -o %t
      5 // RUN: not %run %t
      6 
      7 // Test that buffer overflows on the unsafe stack do not affect variables on the
      8 // safe stack.
      9 
     10 // REQUIRES: stable-runtime
     11 
     12 __attribute__((noinline))
     13 void fct(volatile int *buffer)
     14 {
     15   memset(buffer - 1, 0, 7 * sizeof(int));
     16 }
     17 
     18 int main(int argc, char **argv)
     19 {
     20   int value1 = 42;
     21   int buffer[5];
     22   int value2 = 42;
     23   fct(buffer);
     24   return value1 != 42 || value2 != 42;
     25 }
     26