OpenACC V2.7 Section 3.2.18 acc_malloc says the following:
(OpenACC V3.3 also contains similar texts.)
In case of an error, acc_malloc returns a NULL pointer.
In the following example, however, acc_malloc() crashes instead of returning a NULL pointer.
#include <openacc.h>
#include <stdio.h>
#include <limits>
int main() {
void *ptr = nullptr;
auto alloc_size = std::numeric_limits<size_t>::max() - 42;
printf("==> alloc_size = %zu\n", alloc_size);
ptr = nullptr;
ptr = acc_malloc(alloc_size);
if(!ptr) {
printf("==> acc_malloc(alloc_size) failed!\n");
} else {
printf("==> acc_malloc(alloc_size) returns a valid pointer (%zu)\n", ptr);
}
return 0;
}