brintos

brintos / llvm-project-archived public Read only

0
0
Text · 585 B · 566b115 Raw
24 lines · cpp
1// Regression test for2// https://code.google.com/p/address-sanitizer/issues/detail?id=1833 4// RUN: %clangxx_asan -O2 %s -o %t5// RUN: not %run %t 12 2>&1 | FileCheck %s6// RUN: not %run %t 100 2>&1 | FileCheck %s7// RUN: not %run %t 10000 2>&1 | FileCheck %s8 9#include <stdlib.h>10#include <string.h>11#include <stdio.h>12 13int main(int argc, char *argv[]) {14  fprintf(stderr, "main\n");15  int *x = new int[5];16  memset(x, 0, sizeof(x[0]) * 5);17  int index = atoi(argv[1]);18  unsigned res = x[index];19  // CHECK: main20  // CHECK-NOT: CHECK failed21  delete[] x;22  return (res % 10) + 1;23}24