[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 18:23:39 PST 2023
https://github.com/madanial0 updated https://github.com/llvm/llvm-project/pull/73878
>From 7e70674a3d047d96876d34b1828d61dbc4e64f49 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 | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/flang/runtime/ISO_Fortran_binding.cpp b/flang/runtime/ISO_Fortran_binding.cpp
index ce146844533a064..20bd42adbd8015b 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;
}
+#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