[flang-commits] [flang] [flang] Fix -Wcharacter-conversion warnings (NFC) (PR #155873)
Michael Kruse via flang-commits
flang-commits at lists.llvm.org
Fri Aug 29 06:57:48 PDT 2025
================
@@ -289,7 +289,8 @@ RESULT DecodeString(const std::string &s, bool backslashEscapes) {
DecodeCharacter<ENCODING>(p, bytes, backslashEscapes)};
if (decoded.bytes > 0) {
if (static_cast<std::size_t>(decoded.bytes) <= bytes) {
- result.append(1, decoded.codepoint);
+ result.append(
+ 1, static_cast<typename RESULT::value_type>(decoded.codepoint));
----------------
Meinersbur wrote:
There is the overload `std::u16string DecodeString<std::u16string, Encoding::UTF_8>`. A character outside the unicode basic plane needs more than 16 bits.
According to https://flang.llvm.org/docs/Character.html#kinds-and-character-sets, Fortran strings are expected to be UCS-2 and truncation is expected.
> In particular, conversions between kinds are assumed to be simple zero-extensions or truncation, not table look-ups.
https://github.com/llvm/llvm-project/pull/155873
More information about the flang-commits
mailing list