brintos

brintos / llvm-project-archived public Read only

0
0
Text · 796 B · 3f9a1ce Raw
21 lines · cpp
1// RUN: %clangxx -fsanitize=alignment -fno-sanitize-recover=alignment                           -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --implicit-check-not=" assumption "2 3// RUN: rm -f %tmp4// RUN: echo "[alignment]" >> %tmp5// RUN: echo "fun:main" >> %tmp6// RUN: %clangxx -fsanitize=alignment -fno-sanitize-recover=alignment -fsanitize-ignorelist=%tmp -O0 %s -o %t && %run %t 2>&17 8#include <stdlib.h>9 10int main(int argc, char* argv[]) {11  char *ptr = (char *)malloc(2);12 13  __builtin_assume_aligned(ptr + 1, 0x8000);14  // CHECK: {{.*}}align-assume-ignorelist.cpp:[[@LINE-1]]:32: runtime error: assumption of 32768 byte alignment for pointer of type 'char *' failed15  // CHECK: 0x{{.*}}: note: address is {{.*}} aligned, misalignment offset is {{.*}} byte16 17  free(ptr);18 19  return 0;20}21