]> git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/asan/TestCases/null_deref.cc
New upstream version 1.19.0+dfsg3
[rustc.git] / src / compiler-rt / test / asan / TestCases / null_deref.cc
1 // RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
2 // RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
3 // RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
4 // RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s
5
6 __attribute__((noinline))
7 // FIXME: Static symbols don't show up in PDBs. We can remove this once we start
8 // using DWARF.
9 #ifndef _MSC_VER
10 static
11 #endif
12 void NullDeref(int *ptr) {
13 // CHECK: ERROR: AddressSanitizer: {{SEGV|access-violation}} on unknown address
14 // CHECK: {{0x0*000.. .*pc 0x.*}}
15 ptr[10]++; // BOOM
16 // atos on Mac cannot extract the symbol name correctly. Also, on FreeBSD 9.2
17 // the demangling function rejects local names with 'L' in front of them.
18 // CHECK: {{ #0 0x.* in .*NullDeref.*null_deref.cc:}}[[@LINE-3]]
19 }
20 int main() {
21 NullDeref((int*)0);
22 // CHECK: {{ #1 0x.* in main.*null_deref.cc:}}[[@LINE-1]]
23 // CHECK: AddressSanitizer can not provide additional info.
24 }