brintos

brintos / llvm-project-archived public Read only

0
0
Text · 652 B · dcabb82 Raw
18 lines · cpp
1// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s2// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s3// RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s4// RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s5 6// REQUIRES: compiler-rt-optimized7 8#include <string.h>9int main(int argc, char **argv) {10  char a1[] = {static_cast<char>(argc), 2, 3, 4};11  char a2[] = {1, static_cast<char>(2*argc), 3, 4};12  int res = memcmp(a1, a2, 4 + argc);  // BOOM13  // CHECK: AddressSanitizer: stack-buffer-overflow14  // CHECK: {{#[0-9]+ .*memcmp}}15  // CHECK: {{#[0-9]+ .*main}}16  return res;17}18