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
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