[llvm] [gsymutil] Fix a warning on systems with 32-bit `off_t` (PR #189524)

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 30 20:19:58 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-debuginfo

Author: Justin Bogner (bogner)

<details>
<summary>Changes</summary>

The size of `off_t` isn't specified, so it can be either 32 or 64 bits depending on the system. In particular, on LLP64 systems like windows it's generally only 32 bits. This means the `if (StrtabSize > UINT32_MAX)` check added in #<!-- -->181458 may warn on such systems (Giving -Wsign-compare).

Given that `FileWriter::tell` doesn't even return `off_t`, but `uint64_t`, the simplest fix is to just use the return type of the function instead of potentially truncating.

---
Full diff: https://github.com/llvm/llvm-project/pull/189524.diff


1 Files Affected:

- (modified) llvm/lib/DebugInfo/GSYM/GsymCreator.cpp (+2-2) 


``````````diff
diff --git a/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp b/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
index f26e69fda2540..b4f7a52b2e95e 100644
--- a/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
+++ b/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
@@ -164,9 +164,9 @@ llvm::Error GsymCreator::encode(FileWriter &O) const {
   }
 
   // Write out the string table.
-  const off_t StrtabOffset = O.tell();
+  const uint64_t StrtabOffset = O.tell();
   StrTab.write(O.get_stream());
-  const off_t StrtabSize = O.tell() - StrtabOffset;
+  const uint64_t StrtabSize = O.tell() - StrtabOffset;
   std::vector<uint32_t> AddrInfoOffsets;
 
   // Verify that the size of the string table does not exceed 32-bit max.

``````````

</details>


https://github.com/llvm/llvm-project/pull/189524


More information about the llvm-commits mailing list