12d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
22d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
32d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
42d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s
541f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov
67e8db745c56f7f9317f0d3472bf01bd48ca3424bPeter Collingbourne// REQUIRES: compiler-rt-optimized
77e8db745c56f7f9317f0d3472bf01bd48ca3424bPeter Collingbourne
841f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov#include <string.h>
941f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonovint main(int argc, char **argv) {
1041f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov  char a1[] = {argc, 2, 3, 4};
1141f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov  char a2[] = {1, 2*argc, 3, 4};
1241f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov  int res = memcmp(a1, a2, 4 + argc);  // BOOM
1369d8ede30a0ef32c74af7e4e795eb4b4e7fb1d36Kostya Serebryany  // CHECK: AddressSanitizer: stack-buffer-overflow
1441f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov  // CHECK: {{#0.*memcmp}}
1541f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov  // CHECK: {{#1.*main}}
1641f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov  return res;
1741f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov}
18