Make test more lenient for custom clang version strings
[llvm-project.git] / compiler-rt / test / asan / TestCases / pr33372.cpp
bloba4b606e025c9cbd03b1aeb1edffb2ff56122230b
1 // RUN: %clangxx_asan -O0 -std=c++11 %s -o %t && %run %t 2>&1 | FileCheck %s
2 // RUN: %clangxx_asan -O1 -std=c++11 %s -o %t && %run %t 2>&1 | FileCheck %s
3 // RUN: %clangxx_asan -O2 -std=c++11 %s -o %t && %run %t 2>&1 | FileCheck %s
5 // Test that we do not detect false buffer overflows cased by optimization when
6 // when local variable replaced by a smaller global constant.
7 // https://bugs.llvm.org/show_bug.cgi?id=33372
9 #include <stdio.h>
10 #include <string.h>
12 struct A { int x, y, z; };
13 struct B { A a; /*gap*/ long b; };
14 B *bb;
16 void test1() {
17 A a1 = {1, 1, 2};
18 B b1 = {a1, 6};
19 bb = new B(b1);
22 const char KKK[] = {1, 1, 2};
23 char bbb[100000];
25 void test2() {
26 char cc[sizeof(bbb)];
27 memcpy(cc, KKK , sizeof(KKK));
28 memcpy(bbb, cc, sizeof(bbb));
31 int main(int argc, char *argv[]) {
32 test1();
33 test2();
34 printf("PASSED");
35 return 0;
38 // CHECK-NOT: ERROR: AddressSanitizer
39 // CHECK: PASSED