1 // RUN: %clangxx_asan -O0 %s -o %t
2 // RUN: not %run %t 0 2>&1 | FileCheck %s
3 // RUN: not %run %t 1 2>&1 | FileCheck %s
4 // RUN: not %run %t 2 2>&1 | FileCheck %s
5 // RUN: not %run %t 3 2>&1 | FileCheck %s
6 // RUN: not %run %t 4 2>&1 | FileCheck %s
7 // RUN: not %run %t 5 2>&1 | FileCheck %s
8 // RUN: not %run %t 6 2>&1 | FileCheck %s
9 // RUN: not %run %t 7 2>&1 | FileCheck %s
10 // RUN: not %run %t 8 2>&1 | FileCheck %s
11 // RUN: not %run %t 9 2>&1 | FileCheck %s
12 // RUN: not %run %t 10 2>&1 | FileCheck %s
18 template <class T
> struct Ptr
{
19 void Store(T
*ptr
) { t
= ptr
; }
21 void Access() { *t
= {}; }
26 template <class T
, size_t N
> struct Ptr
<T
[N
]> {
28 void Store(Type
*ptr
) { t
= *ptr
; }
30 void Access() { *t
= {}; }
35 template <class T
> __attribute__((noinline
)) void test() {
43 // CHECK: ERROR: AddressSanitizer: stack-use-after-scope
44 // CHECK: #{{[0-9]+}} 0x{{.*}} in {{(void )?test.*\((void)?\) .*}}use-after-scope-types.cpp
45 // CHECK: Address 0x{{.*}} is located in stack of thread T{{.*}} at offset [[OFFSET:[^ ]+]] in frame
46 // {{\[}}[[OFFSET]], {{[0-9]+}}) 'x'
49 int main(int argc
, char **argv
) {
50 using Tests
= void (*)();
58 &test
<std::vector
<std::string
>>,
65 int n
= atoi(argv
[1]);
66 if (n
== sizeof(tests
) / sizeof(tests
[0])) {