[flang-commits] [flang] [Flang] malloc(1) on AIX as malloc(0) returns nullptr (PR #73878)
via flang-commits
flang-commits at lists.llvm.org
Wed Nov 29 17:14:31 PST 2023
https://github.com/madanial0 updated https://github.com/llvm/llvm-project/pull/73878
>From 82a156eb115e0796688f835a47344c3f3d4648d0 Mon Sep 17 00:00:00 2001
From: Mark Danial <madanial at dixon.rtp.raleigh.ibm.com>
Date: Tue, 28 Nov 2023 22:14:54 -0500
Subject: [PATCH] [Flang] malloc(1) on AIX as malloc(0) returns nullptr
---
flang/runtime/ISO_Fortran_binding.cpp | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/flang/runtime/ISO_Fortran_binding.cpp b/flang/runtime/ISO_Fortran_binding.cpp
index ce146844533a064..e2888464dc83207 100644
--- a/flang/runtime/ISO_Fortran_binding.cpp
+++ b/flang/runtime/ISO_Fortran_binding.cpp
@@ -75,7 +75,14 @@ RT_API_ATTRS int CFI_allocate(CFI_cdesc_t *descriptor,
dim->sm = byteSize;
byteSize *= extent;
}
- void *p{std::malloc(byteSize)};
+ #ifdef _AIX
+ if (!byteSize)
+ void *p{std::malloc(1)};
+ else
+ void *p{std::malloc(byteSize)};
+ #else
+ void *p{std::malloc(byteSize)};
+ #endif
if (!p && byteSize) {
return CFI_ERROR_MEM_ALLOCATION;
}
More information about the flang-commits
mailing list