1 // RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
6 explicit IntHolder(int *val
= 0) : val_(val
) { }
7 __attribute__((noinline
)) ~IntHolder() {
8 printf("Value: %d\n", *val_
); // BOOM
9 // CHECK: ERROR: AddressSanitizer: stack-use-after-scope
10 // CHECK: #0 0x{{.*}} in IntHolder::~IntHolder{{.*}}.cpp:[[@LINE-2]]
12 void set(int *val
) { val_
= val
; }
13 int *get() { return val_
; }
18 int main(int argc
, char *argv
[]) {
19 // It is incorrect to use "x" int IntHolder destructor, because "x" is
20 // "destroyed" earlier as it's declared later.