[llvm] [SystemZ][z/OS] Fix error about const char in Text Encoding (PR #146727)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 2 08:30:39 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-support
Author: Abhina Sree (abhina-sree)
<details>
<summary>Changes</summary>
This patch fixes the following error:
```
llvm/lib/Support/TextEncoding.cpp:274:11: error: cannot initialize a variable of type 'char *' with an rvalue of type 'const char *'
274 | char *Input = InputLength ? const_cast<char *>(Source.data()) : "";
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
---
Full diff: https://github.com/llvm/llvm-project/pull/146727.diff
1 Files Affected:
- (modified) llvm/lib/Support/TextEncoding.cpp (+1-1)
``````````diff
diff --git a/llvm/lib/Support/TextEncoding.cpp b/llvm/lib/Support/TextEncoding.cpp
index b675966c8d822..b4ee0f8ee8bfd 100644
--- a/llvm/lib/Support/TextEncoding.cpp
+++ b/llvm/lib/Support/TextEncoding.cpp
@@ -271,7 +271,7 @@ TextEncodingConverterIconv::convertString(StringRef Source,
// Setup the input. Use nullptr to reset iconv state if input length is
// zero.
size_t InputLength = Source.size();
- char *Input = InputLength ? const_cast<char *>(Source.data()) : "";
+ char *Input = const_cast<char *>(InputLength ? Source.data() : "");
Ret = iconv(ConvDesc, &Input, &InputLength, &Output, &OutputLength);
if (Ret != 0) {
if (auto EC = HandleError(Ret))
``````````
</details>
https://github.com/llvm/llvm-project/pull/146727
More information about the llvm-commits
mailing list