[flang-commits] [flang] [flang] Fix const cast issue in FreeMemory function call in execute_command_line (PR #77906)
Yi Wu via flang-commits
flang-commits at lists.llvm.org
Fri Jan 12 03:04:56 PST 2024
https://github.com/yi-wu-arm created https://github.com/llvm/llvm-project/pull/77906
The FreeMemory function only accepts a void pointer, but it was being called with a const char pointer, resulting in a type-casting issue.
To address this, the commit replaces the direct cast with a const_cast<void *>(static_cast<const void *>(newCmd).
>From 2a36ab7f05771662c361a301f02039757694151a Mon Sep 17 00:00:00 2001
From: Yi Wu <yi.wu2 at arm.com>
Date: Fri, 12 Jan 2024 11:01:06 +0000
Subject: [PATCH] Fix const cast issue in FreeMemory function call
The FreeMemory function only accepts a void pointer,
but it was being called with a const char pointer,
resulting in a type-casting issue.
To address this, the commit replaces the direct cast with a
const_cast<void *>(static_cast<const void *>(newCmd).
---
flang/runtime/execute.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang/runtime/execute.cpp b/flang/runtime/execute.cpp
index 48773ae8114b0b..fa2b7eca0dde69 100644
--- a/flang/runtime/execute.cpp
+++ b/flang/runtime/execute.cpp
@@ -199,7 +199,7 @@ void RTNAME(ExecuteCommandLine)(const Descriptor &command, bool wait,
}
// Deallocate memory if EnsureNullTerminated dynamically allocated memory
if (newCmd != command.OffsetElement()) {
- FreeMemory((void *)newCmd);
+ FreeMemory(const_cast<void *>(static_cast<const void *>(newCmd)));
}
}
More information about the flang-commits
mailing list