1// RUN: %clangxx -fsanitize=alignment %s -o %t
2// RUN: %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NOTYPE
3// RUN: %env_ubsan_opts=report_error_type=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TYPE
4
5#include <stdlib.h>
6
7int main(int argc, char* argv[]) {
8 char *ptr = (char *)malloc(size: 2);
9
10 __builtin_assume_aligned(ptr + 1, 0x8000);
11 // CHECK-NOTYPE: SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior {{.*}}summary.cpp:[[@LINE-1]]:32
12 // CHECK-TYPE: SUMMARY: UndefinedBehaviorSanitizer: alignment-assumption {{.*}}summary.cpp:[[@LINE-2]]:32
13 free(ptr: ptr);
14
15 return 0;
16}
17

source code of compiler-rt/test/ubsan/TestCases/Pointer/align-assume-summary.cpp