-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Flang] malloc(1) on AIX as malloc(0) returns nullptr #73878
Conversation
@llvm/pr-subscribers-flang-runtime Author: None (madanial0) ChangesOn AIX malloc(0) reutrns nullptr, which fails test case Full diff: https://github.com/llvm/llvm-project/pull/73878.diff 1 Files Affected:
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;
}
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
On AIX malloc(0) reutrns nullptr, which fails test case
Evaluate/ISO-Fortran-binding.test
, using malloc(1) in AIX for consistent behaviour