blob: 758311ddc47605a35b66d87f1cb6d220c61c9740 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
// RUN: %clangxx_asan -O0 %s -o %t && not %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O1 %s -o %t && not %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O2 %s -o %t && not %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O3 %s -o %t && not %t 2>&1 | FileCheck %s
// REQUIRES: compiler-rt-optimized
#include <string.h>
int main(int argc, char **argv) {
char a1[] = {argc, 2, 3, 4};
char a2[] = {1, 2*argc, 3, 4};
int res = memcmp(a1, a2, 4 + argc); // BOOM
// CHECK: AddressSanitizer: stack-buffer-overflow
// CHECK: {{#0.*memcmp}}
// CHECK: {{#1.*main}}
return res;
}
|