brintos

brintos / llvm-project-archived public Read only

0
0
Text · 579 B · 356a1ac Raw
27 lines · c
1// RUN: %clang_safestack %s -o %t2// RUN: %run %t3 4#include "utils.h"5 6// Test that loads/stores work correctly for VLAs on the unsafe stack.7 8int main(int argc, char **argv)9{10  int i = 128;11  break_optimization(&i);12  char buffer[i];13 14  // check that we can write to a buffer15  for (i = 0; argv[0][i] && i < sizeof (buffer) - 1; ++i)16    buffer[i] = argv[0][i];17  buffer[i] = '\0';18 19  break_optimization(buffer);20 21  // check that we can read from a buffer22  for (i = 0; argv[0][i] && i < sizeof (buffer) - 1; ++i)23    if (buffer[i] != argv[0][i])24      return 1;25  return 0;26}27