1*673dc3d4SNico Weber // Verify that objects passed by value get red zones and that the copy 2*673dc3d4SNico Weber // constructor is called. 3*673dc3d4SNico Weber // RUN: %clangxx_asan -O0 %s -o %t 4*673dc3d4SNico Weber // RUN: not %run %t 2>&1 | FileCheck %s --implicit-check-not \ 5*673dc3d4SNico Weber // RUN: Assertion{{.*}}failed 6*673dc3d4SNico Weber 7*673dc3d4SNico Weber // ASan instrumentation can't insert red-zones around inalloca parameters. 8*673dc3d4SNico Weber // XFAIL: windows-msvc && asan-32-bits 9*673dc3d4SNico Weber 10*673dc3d4SNico Weber #include <cassert> 11*673dc3d4SNico Weber 12*673dc3d4SNico Weber class A { 13*673dc3d4SNico Weber public: A()14*673dc3d4SNico Weber A() : me(this) {} A(const A & other)15*673dc3d4SNico Weber A(const A &other) : me(this) { 16*673dc3d4SNico Weber for (int i = 0; i < 8; ++i) a[i] = other.a[i]; 17*673dc3d4SNico Weber } 18*673dc3d4SNico Weber 19*673dc3d4SNico Weber int a[8]; 20*673dc3d4SNico Weber A *me; 21*673dc3d4SNico Weber }; 22*673dc3d4SNico Weber bar(A * a)23*673dc3d4SNico Weberint bar(A *a) { 24*673dc3d4SNico Weber int *volatile ptr = &a->a[0]; 25*673dc3d4SNico Weber return *(ptr - 1); 26*673dc3d4SNico Weber } 27*673dc3d4SNico Weber foo(A a)28*673dc3d4SNico Webervoid foo(A a) { 29*673dc3d4SNico Weber assert(a.me == &a); 30*673dc3d4SNico Weber bar(&a); 31*673dc3d4SNico Weber } 32*673dc3d4SNico Weber main()33*673dc3d4SNico Weberint main() { 34*673dc3d4SNico Weber A a; 35*673dc3d4SNico Weber foo(a); 36*673dc3d4SNico Weber } 37*673dc3d4SNico Weber 38*673dc3d4SNico Weber // CHECK: ERROR: AddressSanitizer: stack-buffer-overflow 39*673dc3d4SNico Weber // CHECK: READ of size 4 at 40*673dc3d4SNico Weber // CHECK: is located in stack of thread 41