]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/hwasan/TestCases/stack-oob.c
Vendor import of compiler-rt trunk r351319 (just before the release_80
[FreeBSD/FreeBSD.git] / test / hwasan / TestCases / stack-oob.c
1 // RUN: %clang_hwasan -DSIZE=16 -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
2 // RUN: %clang_hwasan -DSIZE=64 -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
3 // RUN: %clang_hwasan -DSIZE=0x1000 -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
4
5 // REQUIRES: stable-runtime
6
7 #include <stdlib.h>
8 #include <sanitizer/hwasan_interface.h>
9
10 __attribute__((noinline))
11 int f() {
12   char z[SIZE];
13   char *volatile p = z;
14   return p[SIZE];
15 }
16
17 int main() {
18   return f();
19   // CHECK: READ of size 1 at
20   // CHECK: #0 {{.*}} in f{{.*}}stack-oob.c:14
21
22   // CHECK: is located in stack of threa
23
24   // CHECK: SUMMARY: HWAddressSanitizer: tag-mismatch {{.*}} in f
25 }