[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 16:23:07 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-runtime
Author: None (madanial0)
<details>
<summary>Changes</summary>
On AIX malloc(0) reutrns nullptr, which fails test case `Evaluate/ISO-Fortran-binding.test`, using malloc(1) in AIX for consistent behaviour
---
Full diff: https://github.com/llvm/llvm-project/pull/73878.diff
1 Files Affected:
- (modified) flang/runtime/ISO_Fortran_binding.cpp (+5-1)
``````````diff
diff --git a/flang/runtime/ISO_Fortran_binding.cpp b/flang/runtime/ISO_Fortran_binding.cpp
index ce146844533a064..f354430d6106fb9 100644
--- a/flang/runtime/ISO_Fortran_binding.cpp
+++ b/flang/runtime/ISO_Fortran_binding.cpp
@@ -75,7 +75,11 @@ RT_API_ATTRS int CFI_allocate(CFI_cdesc_t *descriptor,
dim->sm = byteSize;
byteSize *= extent;
}
- void *p{std::malloc(byteSize)};
+ void *p;
+ if (_AIX && !byteSize)
+ p = std::malloc(1);
+ else
+ p = std::malloc(byteSize);
if (!p && byteSize) {
return CFI_ERROR_MEM_ALLOCATION;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/73878
More information about the flang-commits
mailing list