[llvm] a4d517d - [SystemZ][z/OS] Fix error about const char in Text Encoding (#146727)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 2 10:45:56 PDT 2025


Author: Abhina Sree
Date: 2025-07-02T13:45:52-04:00
New Revision: a4d517dc38088c8ca6eeb8ea880c24dfa3e5ce7b

URL: https://github.com/llvm/llvm-project/commit/a4d517dc38088c8ca6eeb8ea880c24dfa3e5ce7b
DIFF: https://github.com/llvm/llvm-project/commit/a4d517dc38088c8ca6eeb8ea880c24dfa3e5ce7b.diff

LOG: [SystemZ][z/OS] Fix error about const char in Text Encoding (#146727)

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()) : "";
      |           ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

Added: 
    

Modified: 
    llvm/lib/Support/TextEncoding.cpp

Removed: 
    


################################################################################
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))


        


More information about the llvm-commits mailing list