[LVI] Add trunc to i1 handling. (#124480)
[llvm-project.git] / compiler-rt / test / hwasan / TestCases / Posix / posix_memalign-alignment.cpp
blob5841ca42ceb0337f1c50b7ce0f60ef8a98adac9b
1 // RUN: %clangxx_hwasan -O0 %s -o %t
2 // RUN: %env_hwasan_opts=allocator_may_return_null=0 not %run %t 2>&1 | FileCheck %s
3 // RUN: %env_hwasan_opts=allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NULL
5 #include <stdio.h>
6 #include <stdlib.h>
8 int main() {
9 void *p = reinterpret_cast<void*>(42);
10 int res = posix_memalign(&p, 17, 100);
11 // CHECK: ERROR: HWAddressSanitizer: invalid alignment requested in posix_memalign: 17
12 // CHECK: {{#0 0x.* in .*posix_memalign}}
13 // CHECK: {{#1 0x.* in main .*posix_memalign-alignment.cpp:}}[[@LINE-3]]
14 // CHECK: SUMMARY: HWAddressSanitizer: invalid-posix-memalign-alignment {{.*}} in main
16 printf("pointer after failed posix_memalign: %zd\n", (size_t)p);
17 // CHECK-NULL: pointer after failed posix_memalign: 42
19 return 0;